Wednesday, September 11, 2019

Determine Hosted SQL Server if running on VM or Physical Using Powershell

Problem:- 
You had hundreds of servers and for any kind of reporting or analysis, you need to know current SQL Server hosted environment if it Virtual or Physical Server, so we will use PowerShell to achieve that goal in a simple way as usual😊


Solution:-
Using below Script if you are checking machine locally


Using Below Script if you are dealing with hundreds of Servers Remotely



How to Run above Script Remotely: -
  • You need Windows Version 8.1, Windows Server 2012R2 or above
  • Run Powershell in elevated privilege (As Administrator)
  • Set the Execution policy to bypass by typing (Set-ExecutionPolicy -ExecutionPolicy Bypass )
  • Must enable PS Remoting.
  • Save in text file all Servers IP (i.e C:\Users\Mk.elsawy\Desktop\Servers.txt)
  • Save below Script as  DetermineHostedMachineifVMorPhysicalServerRemotelyUsingPowershell.ps1
  • The script will ask you for a credential that will be used when connecting 
  • Execute the script from Powershell as below 

Click for bigger
Ref:-

No comments:

Post a Comment