{"id":17476,"date":"2022-08-25T12:59:03","date_gmt":"2022-08-25T12:59:03","guid":{"rendered":"https:\/\/zaratechs.com\/?p=17476"},"modified":"2022-08-25T12:59:03","modified_gmt":"2022-08-25T12:59:03","slug":"powershell-vs-wmi-for-windows-management-and-automation-anakage-technologies-2","status":"publish","type":"post","link":"https:\/\/zaratechs.com\/powershell-vs-wmi-for-windows-management-and-automation-anakage-technologies-2\/","title":{"rendered":"Powershell Vs Wmi For Windows Management And Automation – Anakage Technologies"},"content":{"rendered":"\n
WMI (Windows Management Instrumentation) is the technique for querying and changing<\/strong> basic information about any windows server, including SQL Server or Exchange Server. It provides a logical representation and structure of systems and services hosted on the server. Some of the examples of tasks you can do with WMI \u2013<\/p>\n\n\n\n WMI is complicated<\/strong><\/p>\n\n\n\n However with time and features WMI has become slightly difficult to use. Powershell tries to solve few of the problems. Powershell 2.0 supports registry, processes, services, event logs etc. Powershell 3.0 with windows 8 and server 2012, introduced hardware inventory access as storage and network adapters.<\/p>\n\n\n\n Powershell is easy<\/strong><\/p>\n\n\n\n Windows powershell used Get-WmiObject which simplified WMI. It saves minimum of 7 lines\/vbscripts\/perl script as compared to WMI. The single-line commands in powershell are also called cmdlets. The underlying technology of Powershell is still WMI, but the classes are basically wrapped and exposed as functions that behave like Windows PowerShell cmdlets<\/p>\n\n\n\n Powershell can access the below modules \u2013<\/strong><\/p>\n\n\n\n Sample commands in WMI vs Powershell \u2013<\/strong><\/p>\n\n\n\n Advantages of Powershell<\/strong><\/p>\n\n\n\nWMIC Version<\/strong><\/td> Windows Powershell Version<\/strong><\/td><\/tr> wmic bios get caption, manufacturer, smbiosbiosversion, version<\/td> get-wmiobject win32_bios caption, manufacturer, smbiosbiosversion, version<\/td><\/tr> wmic logicaldisk where drivetype=3 get name, freespace, systemname, filesystem, size, volumeserialnumber \/format:list<\/td> get-wmiobject win32_logicaldisk name, freespace, systemname, filesystem, size, volumeserialnumber -filter drivetype=3<\/td><\/tr> wmic process call create \u2018notepad.exe\u2019<\/td> invoke-wmimethod win32_process -name create -argumentlist \u2018notepad.exe\u2019<\/td><\/tr> wmic \/node:<machine name> \/user:<username>\/password:<password> logicaldisk where drivetype=3 get name, freespace, filesystem, size<\/td> Get-wmiobject -ComputerName <machine name> -credential <remote credentials> win32_logicaldisk name, reespace, systemname, filesystem, size, volumeserialnumber -filter drivetype=3<\/td><\/tr> WMIC PROCESS where name=\u2019notepad.exe\u2019 delete<\/td> gwmi win32_process -filter \u201cname=\u2019notepad.exe\u2019\u201d | remove-wmiobject<\/td><\/tr> wmic ENVIRONMENT SET NAME=\u201dTEMP\u201d, VARIABLEVALUE=\u201dNEW\u201d , username=\u201d<system>\u201d<\/td> gwmi win32_environment -filter \u2018Name=\u201dtestvar\u201d and username=\u201d<system>\u201d\u2018 | set-wmiinstance -argument @{variableValue=\u201dtestvalue\u201d}<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n