
ドメイン内のクライアントとそうでないクライアントがあります。特定のローカルユーザーが存在するクライアントを取得して削除する方法を知りたいです。GPOを使用するとドメインクライアントの場合は簡単ですが、非ドメインクライアントの場合はどうでしょうか?Powershellコマンドは知っています。ローカルユーザーを取得そして削除-ローカルユーザーただし、すべての PC で起動するのは避けたいです。何か役立つスクリプトをご存知ですか?
ありがとう
答え1
PSRemotingを有効にする必要があります(ワークグループモード) を非ドメイン マシンにインストールし、リモート処理を使用してこれを実行できます。これらのシステムには、最新の PSv5 がインストールされている、または MS powershellgallery.com のローカル ユーザー管理用のモジュールがインストールされている必要があります。
リモート処理を設定するには、それぞれのマシンに触れる必要があります。
•スタンドアロン(ワークグループ)コンピュータで PowerShell リモート処理を有効にする
•2 つのワークグループ マシン間の PowerShell リモート処理
•スタンドアロン ワークグループ コンピューター間の PowerShell PS リモート処理
•2 つのワークグループ マシン間の PowerShell リモート処理
各記事を読んで詳細をすべて把握してください。要約すると、次のようになります。
### Remote Computer
NetConnectionProfile -NetworkCategory Private
Enable-PSRemoting -SkipNetworkProfileCheck -Force
Set-NetFirewallRule –Name "WINRM-HTTP-In-TCP-PUBLIC" –RemoteAddress Any
### Local computer
# Review teh trusted host file
Get-Item WSMan:\localhost\Client\TrustedHosts
# Set the trusted a specific target
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "10.0.2.33" -Force
# Or for several hosts if you don't want to specify them individually
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force
# Connect to a host
Enter-PSSession -ComputerName 10.0.2.33 -Credential $Credentials
実行できるPowerShellコマンドがいくつかありますリモート処理が有効になっていない:
•リモート処理や WinRM を使用せずに Windows PowerShell でリモート操作する
Get-WinEvent
Get-Counter
Get-EventLog
Clear-EventLog
Write-EventLog
Limit-EventLog
Show-EventLog
New-EventLog
Remove-EventLog
Get-WmiObject
Get-Process
Get-Service
Set-Service
Get-HotFix
Restart-Computer
Stop-Computer
Add-Computer
Remove-Computer
Rename-Computer
Reset-ComputerMachinePassword
または、MS Sysinternals PSExec.exe ツールを使用します。