Hi,
I am getting the blank output for below without any error.
Please help.
$reportlocation1 = ".\Servs.csv"
$WPassword = "Password2"
$code = @'
"### Output ###"
Get-NetAdapterBinding -ComponentID ms_tcpip6 | Select @{N="Computer";E={$($env:COMPUTERNAME)}},@{N="ETH_Name";E={$_.Name}},@{N="ETH_DisplayName";E={$_.DisplayName}},@{N="Status";E={$_.Enabled}} | ConvertTo-Csv -UseCulture -NoTypeInformation
'@
$report = @()
$notFound = @()
Import-Csv -Path $reportlocation1 -UseCulture -PipelineVariable row | where {($_.OS -match "Windows")} |
ForEach-Object -Process {
$found = $false
foreach ($pswd in $WPassword) {
$pass = ConvertTo-SecureString -AsPlainText $pswd -Force
$Creds = New-Object System.Management.Automation.PSCredential ("admin", $pass)
$sInvoke = @{
VM = $row.Name
GuestCredential = $Creds
ScriptTYpe = 'powershell'
ScriptText = $code
ErrorAction = 'Stop'
}
try {
$result = Invoke-VMScript @sInvoke
$dummy, $out1 = $result.ScriptOutput -split '### Output ###'
$out1 = $out1.TrimStart("`n`r")
$report += $row | ConvertFrom-Csv -UseCulture | Select @{N="Computer";E={$($env:COMPUTERNAME)}},@{N="ETH_Name";E={$_.Name}},@{N="ETH_DisplayName";E={$_.DisplayName}},@{N="Status";E={$_.Enabled}}
$found = $true
break
}
catch {
}
}
if(-not $found){
$notFound += $row
}
}
$report | Format-Table -AutoSize
$notFound | Format-Table -AutoSize