コード:デバッグする方法 "X 'という用語は、コマンドレット、関数、スクリプトファイル、または実行可能なプログラムの名前として認識されません"?
G$Folders = Get-childItem C:\permissiontest\
$InheritanceFlag = [System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor [System.Security.AccessControl.InheritanceFlags]::ObjectInherit
$PropagationFlag = [System.Security.AccessControl.PropagationFlags]::InheritOnly
$objType = [System.Security.AccessControl.AccessControlType]::Allow
foreach ($TempFolder in $Folders)
{
echo "Loop Iteration"
$Folder = $TempFolder.FullName
$acl = Get-Acl $Folder
$permission = "MRGROUP\ro","Read", $InheritanceFlag, $PropagationFlag, $objType
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl.SetAccessRule($accessRule)
Set-Acl $Folder $acl
}
エラー:
G$Folders : The term 'G$Folders' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At C:\script\aclper.ps1:1 char:1
+ G$Folders = Get-childItem C:\permissiontest\
+ ~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (G$Folders:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
まあ 'G $ Folders'はコマンドではありません。 'G $ name'は何を期待しますか?おそらく、Gを取り除き、最初の行に '$ Folders ='にします。 – TessellatingHeckler
ようこそStackOverflowへ。人々が助けてくれるようにするには、少なくともあなたの質問に少しでも力を入れてください。文字通り、文脈なしであなたのスクリプトとエラーをダンプしました。あなたはそれをフォーマットする時間を取らなかった(私はあなたのためにやった)。 –