更改计算机名称:
1 #重命名计算机,加入工作组 2 $NewComputerName = "WEB" 3 $workgroup = "WKGROUP" 4 $ComputerInfo = Get-WmiObject -Class Win32_ComputerSystem 5 $ComputerInfo.rename($NewComputerName) 6 $ComputerInfo.JoinDomainOrWorkgroup($workgroup)
更改计算机名称Function:
1 Function Rename-Computer( $NewName,$AutoRestart=$false ) 2 { 3 $computer=Get-WMIObject Win32_ComputerSystem 4 $null = $computer.Rename( $NewName ) 5 if($AutoRestart) { Restart-Computer -Force } 6 }
修改密码:
#修改Administrator密码 Write-host "当前管理员密码已设置为:$userpass" -ForegroundColor Red $computerName=$env:computername $username="administrator" $u = [ADSI]"WinNT://$computerName/$userName,User" $u.SetPassword($userpass) $u.SetInfo()