Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

trying to set time on remote machines

$
0
0

Hi
I would like to set the time on remote machines joined to a domain.
I only want it to only apply to machines turned on.
I am getting these errors when I run the script below

CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
    + FullyQualifiedErrorId : InvalidResourceUri,PSSessionOpenFailed

The WS-Management service cannot process the request. Cannot find the Microsoft.PowerShell session configuration in the WSMan

 

import-module ActiveDirectory
$Computers = Get-ADcomputer -filter {OperatingSystem -NotLike "*server*"}
foreach ($Computer in $Computers)
{
    $name = $computer.Name
    if (Test-Connection -Computername $name -BufferSize 16 -Count 1 -quiet )
    {
    $Session= New-PSSession -computername $name -authentication Kerberos
     Invoke-Command -ComputerName $name -script {NET TIME /DOMAIN:TEST /set /yes}}
    Remove-PSSession $Session
}

 

Thank you in advance


Viewing all articles
Browse latest Browse all 6937

Trending Articles