Last active
September 10, 2019 21:54
in this script, I am trying to Determine SQL Server hosted servers if it's VM or Physical Remotely using Powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Servers = Read-Host "Please Add Text File Path that Contain all servers IP " | |
$Target = Get-Content -Path $Servers | |
$hosted = Invoke-Command -ComputerName $Target -ScriptBlock {Get-wmiobject win32_computersystem | | |
Where-Object model -EQ 'Virtual Machine'} -Credential (Get-Credential) | |
$result=@() | |
if ($hosted) | |
{ | |
$result+=New-Object -TypeName PSObject -Property ([ordered]@{ | |
'Computer IP'=$hosted.PSComputerName; | |
'Hosted On'=$hosted.Model; | |
}) | |
} | |
else | |
{ | |
$result+=New-Object -TypeName PSObject -Property ([ordered]@{ | |
'Computer IP'=$hosted.PSComputerName; | |
'Hosted On'='Physical Server'; | |
}) | |
} | |
Write-Output $result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment