$ComputerInfo = Get-WmiObject -Class Win32_ComputerSystem
$ComputerInfo.rename($NewComputerName)
}
This script shows you how to rename computer by using WMI
How to use it :
& .\rename-computerName.ps1
rename-computername "MyNewComputerNAME"
And to reboot you can use WMI class Win32_OperatingSystem and its method reboot():
$OS = Get-WmiObject -Class Win32_OperatingSystem
$OS.reboot()
OR
shutdown -r -t 10 -f -c "Restart OS"
Users of PowerShell V2 (currently CTP3) can use the Restart-Computer cmdlet too. :)
DETAILED DESCRIPTION
The Restart-Computer cmdlet restarts the operating system on the local and remote computers.
You can use the parameters of Restart-Computer to run the restart operations as a background job, to specify the authentication levels and alternate credentials, to limit the operations that run concurrently, and to force an immediate restart.
This cmdlet does not require Windows PowerShell remoting unless you use the AsJob parameter.
No comments:
Post a Comment