Several cmdlets in Windows PowerShell 2.0 have new parameters. Perhaps the most imme¬diately useful parameter is the
−computername parameter, which allows you to work with computers in a remote fashion. The following modified cmdlets now add the
–computername parameter.
- Get-EventLog Gets the events in an event log or a list of the event logs on local or remote computers. The following command uses the −computername parameter with the Get-EventLog cmdlet to retrieve the most recent event from the application log on a remote computer named berlin:
Get-EventLog -ComputerName berlin -LogName application -Newest 1
- Get-Process Gets the processes that are running on a local or remote computer. The following command uses the new –computername parameter with the Get-Process cmdlet to obtain a listing of the processes currently running on a remote computer named berlin:
Get-Process -ComputerName berlin
- Get-Service Gets the services on a local or remote computer. By using the –computername parameter with the Get-Service cmdlet, you can obtain a listing of the status of all of the services that are defined on a remote computer named berlin:
Get-Service -ComputerName berlin
- Set-Service Starts, stops, and suspends a service and changes its properties. The Set-Service cmdlet also has been updated to include the –computername parameter. As shown here, the new parameter is used to connect to a remote computer named berlin and to change the startup type of the service to manual. Because the Set-Service cmdlet is modifying the system state, it uses the –confirm switch to ensure that you are working with both the correct computer and the correct service:
Set-Service -ComputerName berlin -Name bits -StartupType manual –Confirm