小编sim*_*pen的帖子

无法从函数内部修改脚本范围的变量

我目前正在制作一个脚本,该脚本应该连接到 42 个不同的本地服务器,并从活动目录获取特定组的用户(fj\xc3\xa4rrskrivbordsanv\xc3\xa4ndare(瑞典语远程桌面用户:D))。从服务器获取所有用户后,它必须将用户导出到我的桌面上的文件中

\n\n

csv 文件必须如下所示:

\n\n
Company;Users\nLawyerSweden;Mike\nLawyerSweden;Jennifer\nStockholm Candymakers;Pedro\n(Examples) \netc.\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是目前的代码:

\n\n
cls\n\n$MolnGroup = \'fj\xc3\xa4rrskrivbordsanv\xc3\xa4ndare\' \n$ActiveDirectory = \'activedirectory\' \n$script:CloudArray\nSet-Variable -Name OutputAnvandare -Value ($null) -Scope Script\nSet-Variable -Name OutputDomain -Value ($null) -Scope Script\n\nfunction ReadInfo {\n\nWrite-Host("A")\n\nGet-Variable -Exclude PWD,*Preference | Remove-Variable -EA 0\n\nif (Test-Path "C:\\file\\frickin\\path.txt") {\n\n    Write-Host("File found")\n\n}else {\n\n    Write-Host("Error: File not found, filepath might be invalid.")\n    Exit\n}\n\n\n$filename = "C:\\File\\Freakin\'\\path\\super.txt"\n$Headers = "IPAddress", "Username", "Password", "Cloud"\n\n$Importedcsv = Import-csv $filename -Delimiter ";" -Header $Headers\n\n$PasswordsArray += @($Importedcsv.password)\n$AddressArray = @($Importedcsv | ForEach-Object { $_.IPAddress } )\n$UsernamesArray += …
Run Code Online (Sandbox Code Playgroud)

powershell scope powershell-2.0 powershell-remoting powershell-3.0

1
推荐指数
1
解决办法
1636
查看次数