复制项目 Powershell Intune 脚本缺少权限。我可能缺少哪些权限?

问题描述 投票:0回答:1

我正在使用“修改后的脚本”来导出用户在浏览器上安装的扩展。我让它以管理员身份在本地计算机上运行。它创建扩展的 CSV,然后将其推送到文件共享服务器。作为管理员,我可以在本地执行此操作,但当我将脚本推送到 Intune 时,它似乎中断了。 我从日志中提取的错误向我展示了这一点。我不确定我可能会缺少什么权限,因为我是两个系统的管理员并且拥有完全访问权限。

我唯一的想法是 Intune 在与我指定的目录不同的目录中运行代码。

<![LOG[[PowerShell] Fail, the details are {"Version":1,"SigningCode":649,"EncryptionCode":633,"SigningMsg":"(Success) AccountId:23a4e529-8d4a-4b13-936b-f2219c4fdc05,PolicyId:50e3bb39-e555-45d6-bedc-4ec27056f1b5,Type:1,Enforce: Enforcement1. OSVersion:10.0.19045,AgentVersion:1.77.112.0. ","EncryptMsg":"run in legacy mode","ExecutionMsg":"Copy-Item : Access is denied\r\nAt C:\\Program Files (x86)\\Microsoft Intune Management \r\nExtension\\Policies\\Scripts\\c6f32f80-ea57-4beb-8f7e-49ac55513f86_50e3bb39-e555-45d6-bedc-4ec27056f1b5.ps1:657 char:1\r\n+ Copy-Item -Path $Path -Destination $destinationFolderPath -Recurse -F ...\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : NotSpecified: (:) [Copy-Item], UnauthorizedAccessException\r\n + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.CopyItemCommand\r\n \r\n\r\n"}]LOG]!><time="16:59:05.8654768" date="4-1-2024" component="IntuneManagementExtension" context="" type="3" thread="32" file="">

这些是我添加的部分,以使其能够在我将其放入并手动运行的任何系统上运行。

#Define network folder Path $destinationFolderPath = "\\FAKE IP\\shared\\debug_data" $SourcePath = "$env:USERPROFILE\\Documents\\Browser_Plugins" # Extract the file path and remove ".ad" characters $Path = $SourcePath -replace ".ad", "" Write-Host "Modified path: $Path" #If the path does not exist create it if (-not (Test-Path -Path $Path)) { New-Item -Path $Path -ItemType Directory -Force }

这是复制到不同服务器部分。

# get unique values for the CSVs, while sorting at the same time #$SimplifiedExtensionDataCSV = $SimplifiedExtensionDataCSV | Sort-Object Username,BrowserEngine,BrowserCompany,BrowserName,ExtensionUnpacked,ExtensionID,ExtensionVersion,ExtensionEnabled -Unique $ExtensionsOnlyCSV = $ExtensionsOnlyCSV | Sort-Object BrowserEngine,ExtensionURLs,ExtensionUnpacked,ExtensionVendor,ExtensionName,ExtensionID,ExtensionDescription -Unique # export finialized data #$OriginalExtensionDataJSON | ConvertTo-Json -Compress -Depth 100 | Out-File "${Path}${FILENAME_PRE}_original_${FILENAME_POST}.json" -Encoding utf8 #$SimplifiedExtensionDataCSV | Export-Csv -NoTypeInformation "${Path}${FILENAME_PRE}_simplified_${FILENAME_POST}.csv" -Encoding utf8 $ExtensionsOnlyCSV | Export-Csv -NoTypeInformation "${Path}${FILENAME_PRE}_only_${FILENAME_POST}.csv" -Encoding utf8 Write-Output "Data exported to folder: `"${Path}\`"" #Copy the data Copy-Item -Path $Path -Destination $destinationFolderPath -Recurse -Force # Display a message indicating successful copy #Write-Host "Folder copied successfully to $destinationFolderPath."

当我将代码上传到 intune 时,我希望它在登录用户上运行 - 这将是我在测试中并在其目录中作为管理脚本运行。当我删除复制部分时,它会运行,但我没有看到文件 - 它表示它在 Intune 中成功。当我添加复制部分时,它出错了。

当我在本地运行它时,它在任何机器上都运行得很好,我把它放上 - 我必须提升到管理员级别,但它按预期工作。

azure powershell intune
1个回答
0
投票

#Requires -RunAsAdministrator

© www.soinside.com 2019 - 2024. All rights reserved.