コンピューター名変更
Powershel 3.0の標準コマンドで変更
Rename-Computer -ComputerName <oldName> -NewName <newName> [-Restart]
コマンド実行後、再起動を行うには、コマンドに-Restartをつけます
WMIを使ってコンピューター名を変更
(Get-WmiObject -Class Win32_ComputerSystem).Rename("newName")
サーバー再起動する
Restart-Computer
Windows ファイアーウォールを無効/有効1)プライベートネットワーク、パブリックネットワーク、ドメインネットワークで全て無効
Get-NetFirewallProfile | Set-NetFirewallProfile -Enabled false
2)パブリックネットワークだけで無効
Get-NetFirewallProfile -Name Public | Set-NetFirewallProfile -Enabled false
3)ファイアーウォールを有効にするには、"false"を"true"に書き換えればいい。
リモートデスクトップ接続を有効/無効
Powershell3.0で対応するコマンドが無さそうなので、WMIを使う
1)有効にする
(Get-WmiObject win32_TerminalServiceSetting -Namespace root\cimv2\TerminalServices).SetAllowTSConnections(1)
2)無効にする
(Get-WmiObject win32_TerminalServiceSetting -Namespace root\cimv2\TerminalServices).SetAllowTSConnections(0)
ドメイン参加
$admin = "test\administrator"
$password = "P@ssw0rd"
$pass = ConvertTo-SecureString $pwd -AsPlainText -Force
$domainCredential = New-Object System.Management.Automation.PSCredential $admin, $pass
Add-Computer -DomainName "test.local" -ComputerName "testpc" -Credential $domainCredential -OUPath "OU=HR" -Restart -Force