January 2009 - Posts
When I try to ping a brand new install of Windows 7 (beta). I got the “Request Timed out” error and when I try to use PowerShell to restart the Windows 7 box remotely, I got the below error:
Restart-Computer -computername neptune
Restart-Computer : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
At line:1 char:17
+ Restart-Computer <<<< -computername neptune
+ CategoryInfo : InvalidOperation: (:) [Restart-Computer], COMException
+ FullyQualifiedErrorId : RestartComputerException,Microsoft.PowerShell.Commands.RestartComputerCommand
How to fix this?
On the Windows 7 box, I go to Control Panel – Windows Firewall, in "Allow programs to communicate through Windows Firewall” I enabled “File and Printer Sharing” and “Windows Management Instrumentation(WMI)”, I am now able to ping the Windows 7 box successfully. When I try to restart-computer again, I get a new error:
Restart-Computer -computername neptune
Restart-Computer : This command cannot be executed on target computer('neptune') due to following error: The system shu
tdown cannot be initiated because there are other users logged on to the computer.
At line:1 char:17
+ Restart-Computer <<<< -computername neptune
+ CategoryInfo : InvalidOperation: (neptune:String) [Restart-Computer], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.RestartComputerCommand
What if I insist to reboot the Windows 7 box, Yes I can!
Restart-Computer –computername neptune -force
In case you haven't noticed, Microsoft renamed Terminal Services as Remote Desktop Services from Windows 2008 R2 onwards! It does caught me by surprise to get used to the new NAME!
But I am happy to report that the beta release of Windows server 2008 R2 supports managing Remote Desktop Service(Terminal Services) using PowerShell!
The PowerShell provider comes with the Remote Desktop Services role, once you have the RDS role enabled, the PowerShell provider lets you to configure and manage all the Remote Desktop Services related tasks.
Microsoft Remote Desktop Service Program Manager Shanmugam Kulandaivel has a detailed article here to help you get started. I do want to point out that you will need to have PowerShell installed on the managed servers in order to use RDS PowerShell provider!
This is one step further toward the ultimate goal - PowerShell everywhere, ie all the windows management interface and the web management interface will be build on PowerShell. Stay tuned!
In this post, I explore the ways to get remote registry key property. Here is a PowerShell script to create a new registry key value in remote registry.
$colComputers = gc c:\myworkspace\computerlist.txt
foreach ($strComputer in $colComputers)
{
#Open remote registry
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $strComputer)
#Open the targeted remote registry key/subkey for read and write ($True)
$regKey= $reg.OpenSubKey("SOFTWARE\\Whatever\\General",$True)
#Create a new (string)value –“Override System Verification” and assign “Yes” to it
$regKey.Setvalue('Override System Verification', 'Yes', 'String')
In my previous post, I described the restart-computer cmdlet. There is also a sister cmdlet. Yes, you guessed it right: Shutdown-computer
Shutdown-computer –computername (gc c:\temp\serverlist.txt) –force –throttlelimit 10
You could force the immediate shutdown of multiple remote computers and shutdown 10 at a time!
Right before Christmas, PowerShell team released Windows PowerShell V2 Community Technology Preview 3 (CTP3). There is a new cmdlets caught my eye, see below
gc c:\Temp\ServerList.txt |%{Restart-computer –computername $_ –force}
It gets a list of computers and force the immediate restart!
It’s very handy and also can be very dangerous, you could potentially reboot every single computer in your company!
Get-QADComuter|%{Restart-Computer –computername $_ –force –throtllelimit 1-}