update
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
$PowerBi = Import-Csv -Path D:\Downloads\serverinventory20251002.csv
|
||||
$SRM = Import-Csv -Path D:\Downloads\itdvmvc1.nd.gov-itdvmvc2.nd.gov-20251002-102657.csv
|
||||
$VMs = Get-VM | Where-Object { $_.ExtensionData.summary.config.ManagedBy.Type -eq "placeholderVm" }
|
||||
|
||||
$Result = [System.Collections.ArrayList]@()
|
||||
foreach ($pbi in $PowerBi) {
|
||||
Write-Verbose -Message ($pbi.'Host Name') -Verbose
|
||||
$obj = $null
|
||||
|
||||
$obj = [PSCustomObject]@{
|
||||
PowerBi = $pbi.'Host Name'
|
||||
Placeholder = $VMs | Where-Object Name -EQ $pbi.'Host Name' | Select-Object -ExpandProperty Name -First 1;
|
||||
SRM = $SRM | Where-Object "Virtual Machine" -EQ $pbi.'Host Name' | Select-Object -ExpandProperty "Virtual Machine"
|
||||
CMDB = ((Get-ITDServiceNowRecord -Table cmdb_ci_server -Filter ("name=" + $pbi.'Host Name'.split('.')[0])).name.display_value)
|
||||
}
|
||||
$null = $Result.Add($obj)
|
||||
}
|
||||
|
||||
foreach ($VM in $VMs) {
|
||||
if ($Result | Where-Object Placeholder -EQ $VM.Name) {
|
||||
#do nothing
|
||||
}
|
||||
else {
|
||||
Write-Verbose -Message ($VM.Name) -Verbose
|
||||
$obj = [PSCustomObject]@{
|
||||
PowerBi = $PowerBi | Where-Object 'Host Name' -EQ $pbi.'Host Name'
|
||||
Placeholder = $VM.Name;
|
||||
SRM = $SRM | Where-Object "Virtual Machine" -EQ $pbi.'Host Name'
|
||||
CMDB = ((Get-ITDServiceNowRecord -Table cmdb_ci_server -Filter ("name=" + $pbi.'Host Name'.split('.')[0])).name.display_value);
|
||||
}
|
||||
$null = $Result.Add($obj)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user