Hi,
I am unable to get output from remote VMs using below script. There is no errors.
Please help
Script
$reportlocation2 = "D:\reports\Shared_OS_Info1.csv"
$reportlocation = "D:\reports\Shared_Patching_Info.xlsx"
$Today = (Get-Date)
$StartDate = $Today.Date.AddDays(-10)
$EndDate = $Today.Date.AddDays(1)
Import-Csv -Path $reportlocation2 -UseCulture -PipelineVariable row |
ForEach-Object -Process {
try{
$patchcount = Invoke-Command -ComputerName $_.Name -ScriptBlock {(Get-HotFix | Where {$_.InstalledOn -gt $using:StartDate -AND $_.InstalledOn -lt $using:EndDate }).count}
}
catch
{
$patchcount = 'NA'
}
$row | Add-Member -MemberType NoteProperty -Name 'Patch_Count' -Value $patchcount -PassThru
} | Export-Excel -Path $reportlocation