gpt4 book ai didi

powershell - 表达式或语句中出现意外的标记 'server'

转载 作者:行者123 更新时间:2023-12-03 08:06:52 28 4
gpt4 key购买 nike

$ServerList = Get-Content "C:\Users\munjanga\Desktop\Execute\Testing\servers.txt"
$ServerList

$Header="FolderPath,IdentityReference,AccessControlType,IsInherited,InheritedFlags,PropagationFlags"

Add-Content -Value $Header -Path $Output

Foreach ($Server in $ServerList) {
$output = "\\C:\Users\munjanga\Desktop\Repositroy "$server.output.csv"
Del $Output -ErrorAction SilentlyContinue

$RootPath ="\\$Server\C:\system.sav"

$Folders = dir $RootPath -recurse | where {$_.psiscontainer -eq $true} -ErrorAction SilentlyContinue

Add-Content -Value "$Header" -Path $Output

Foreach ($Folder in $Folders){

$ACLs = get-acl $Folder.fullname | ForEach-Object { $_.Access }

Foreach ($ACL in $ACLs){

$OutInfo = $Folder.Fullname + "," + $ACL.IdentityReference + "," + $ACL.AccessControlType + "," + $ACL.IsInherited + "," + $ACL.InheritanceFlags + "," + $ACL.PropagationFlags

Add-Content -Value $OutInfo -Path $output -ErrorAction SilentlyContinue
}
}
}

最佳答案

您在此行上有一个格式错误的字符串文字:

$output = "\\C:\Users\munjanga\Desktop\Repositroy "$server.output.csv"
--^

上面指出的 "不应该存在。我想你打算写:

$output = "\\C:\Users\munjanga\Desktop\Repositroy\$server.output.csv"

字符串开头的双正斜杠也可能不正确。也许应该将其删除:

$output = "C:\Users\munjanga\Desktop\Repositroy\$server.output.csv"

关于powershell - 表达式或语句中出现意外的标记 'server',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24346005/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com