sync
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
$Subscriptions = Get-AzSubscription
|
||||
|
||||
$AzureVMs = [System.Collections.ArrayList]@()
|
||||
ForEach ($Subscription in $Subscriptions) {
|
||||
Set-AzContext -Subscription $Subscription
|
||||
|
||||
$AllVMs = Get-AzVM
|
||||
|
||||
ForEach ($VM in $AllVMs) {
|
||||
$VMSize = $null
|
||||
$VMSizeSpecs = $null
|
||||
$OSDisk = $null
|
||||
$DataDisks = $null
|
||||
$obj = $null
|
||||
|
||||
$VMSize = $VM.HardwareProfile.VMSize
|
||||
$VMSizeSpecs = Get-AzVMSize -Location $VM.Location | Where-Object { $_.Name -eq $VMSize }
|
||||
|
||||
$OSDisk = $VM.StorageProfile.OSDisk
|
||||
$DataDisks = $VM.StorageProfile.DataDisks
|
||||
|
||||
#$IpAddress = (Get-AzNetworkInterface | Where-Object {$_.Id -eq $VM.NetworkProfile.NetworkInterfaces.Id}).IpConfigurations.PrivateIpAddress
|
||||
|
||||
$obj = [PSCustomObject]@{
|
||||
VMName = $VM.Name
|
||||
Subscription = $Subscription.Name
|
||||
ComputerName = $VM.OSProfile.ComputerName
|
||||
Size = $VMSize
|
||||
CPU = $VMSizeSpecs.NumberOfCores
|
||||
Memory = ($VMSizeSpecs.MemoryInMb / 1024)
|
||||
TotalDisk = ($OSDisk.DiskSizeGB + ($DataDisks.DiskSizeGB | Measure-Object -Sum).Sum)
|
||||
OsDiskGB = $OSDisk.DiskSizeGB
|
||||
DataDisksGB = $DataDisks.DiskSizeGB -join ", "
|
||||
}
|
||||
|
||||
$null = $AzureVMs.Add($obj)
|
||||
}
|
||||
}
|
||||
|
||||
$SharePointList = Get-ITDVMwareSharePointVMGuestList | Where-Object { $_.Status -notlike "D*" -and ($_.DataCenter -like "MAC*" -or $_.DataCenter -like "MAG*") }
|
||||
|
||||
$AzureToSharePointCompare = [System.Collections.ArrayList]@()
|
||||
|
||||
ForEach ($AzVM in $AzureVMs) {
|
||||
$SPItem = $null
|
||||
|
||||
Write-Verbose -Message ("Start " + $AzVM.VMName) -Verbose
|
||||
|
||||
$SPItem = $SharePointList | Where-Object { $_.Title -match $AzVM.VMName.split('-')[1] }
|
||||
Write-Verbose -Message ("Found " + $SPItem.Count + " possible SharePoint matches") -Verbose
|
||||
|
||||
$obj = [PSCustomObject]@{
|
||||
AzVMName = $AzVM.VMName;
|
||||
#AzComputerName = $AzVM.ComputerName
|
||||
SPTitle = $SPItem.Title;
|
||||
CPU = $null;
|
||||
MemoryGB = $null;
|
||||
DiskTotal = $null;
|
||||
}
|
||||
|
||||
|
||||
Write-Verbose -Message "One match found, starting compare"
|
||||
|
||||
If ($SPItem.Processors -ne $AzVM.CPU) {
|
||||
$obj.CPU = $false
|
||||
}
|
||||
Else {
|
||||
$obj.CPU = $true
|
||||
}
|
||||
|
||||
If ($SPItem.RAM -ne $AzVM.Memory) {
|
||||
$obj.MemoryGB = $false
|
||||
}
|
||||
Else {
|
||||
$obj.MemoryGB = $true
|
||||
}
|
||||
|
||||
$SPDiskTotalGB = $SPItem.Disk1 + $SPItem.Disk2 + $SPItem.Disk3 + $SPItem.Disk4
|
||||
If ($SPDiskTotalGB -ne $AzVM.TotalDisk) {
|
||||
$obj.DiskTotal = $false
|
||||
}
|
||||
Else {
|
||||
$obj.DiskTotal = $true
|
||||
}
|
||||
|
||||
$null = $AzureToSharePointCompare.Add($obj)
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user