With commands run in PowerShell, I’m referring to the version that comes with Windows 10 (5.1), most scripts or commands run without error unless there is a problem with the script or command.
I used a script from Idera to check skew on machines and this script works perfectly when run in the current PowerShell window but it also works perfectly in PowerShell V7. Here is the script used, take note it’s not my script:
$Servers = ‘localhost’,’127.0.0.1′
$w32tm = Invoke-Command -Computer $Servers -ArgumentList $Servers -Scriptblock {
Param ($Servers)
Foreach ($Server in $Servers)
{
$Check = w32tm /monitor /computers:$Server /nowarn
$ICMP = (($Check | Select-String “ICMP”)-Replace “ICMP: ” , “”).Trim()
$ICMPVal = [int]($ICMP -split “ms”)[0]
$Source = “ntp.domain.com”
# $Source = w32tm /query /source
$Name = Hostname
Switch ($ICMPVal)
{
{$ICMPVal -le 0} {$Status = "Optimal time synchronisation"}
#you probably need another value here since you'll get no status if it is between 0 and 2m
{$ICMPVal -lt 100000} {$Status = "0-2 Minute time difference"}
{$ICMPVal -ge 100000} {$Status = "Warning, 2 minutes time difference"}
{$ICMPVal -ge 300000} {$Status = "Critical. Over 5 minutes time difference!"}
}
$String = $Name + " - $Status " + "- $ICMP " + " - Source: $Source"
Write-Output $String
}
}
$w32tm
As you can see above, calling windows commands works well in PowerShell V7.
Hope it helps.