NET USE
とNET USER
コマンドをリモートマシンで正常に使用できます。どうしてですかNET LOCALGROUP
?Invoke-Command {net localgroup}が失敗するのはなぜですか?
PS C:\src\powershell> Invoke-Command -ComputerName OTHERMACHINE -ScriptBlock { & NET LOCALGROUP }
System error 1312 has occurred.
+ CategoryInfo : NotSpecified: (System error 1312 has occurred.:String) [], Rem
oteException
+ FullyQualifiedErrorId : NativeCommandError
+ PSComputerName : OTHERMACHINE
A specified logon session does not exist. It may already have been terminated.
/USERパラメータを渡すと、別のエラーが発生します。
PS C:\src\powershell> Invoke-Command -ComputerName OTHERMACHINE -ScriptBlock { & net localgroup /USER:THEDOM\theuser }
The option /USER:THEDOM\theuser is unknown.
+ CategoryInfo : NotSpecified: (The option /USE...son is unknown.:String) [], R
emoteException
+ FullyQualifiedErrorId : NativeCommandError
+ PSComputerName : OTHERMACHINE
The syntax of this command is:
NET LOCALGROUP
[groupname [/COMMENT:"text"]] [/DOMAIN]
groupname {/ADD [/COMMENT:"text"] | /DELETE} [/DOMAIN]
groupname name [...] {/ADD | /DELETE} [/DOMAIN]
More help is available by typing NET HELPMSG 3506.
netコマンドで(/ user:Domain \ username経由で)ユーザー名を渡そうとしましたか? –
@PeterSchneider - はい、別のエラー出力を生成します。 – lit
[this](https://stackoverflow.com/questions/21147784/net-localgroup-administrators-equivalent-in-powershell)...を見ましたか? –