Category Archives: PowerShell and CIM

Find the logged on user

One method of finding the logged on users is to use CIM $ComputerName = $env:COMPUTERNAME Get-CimInstance -ClassName Win32_Process -ComputerName $ComputerName -Filter “Name = ‘explorer.exe'” | foreach {         $lguser = Invoke-CimMethod -InputObject $psitem -MethodName GetOwner         $Properties = … Continue reading

Posted in PowerShell and CIM, PowerShell and WMI | Leave a comment

Are your domain controllers real?

A question on the forum asked about discovering if domain controllers are physical or virtual machines. This will do the job foreach ($domain in (Get-ADForest).domains) {   Get-ADDomainController -filter * -server $domain |   sort hostname  |   foreach { … Continue reading

Posted in PowerShell and Active Directory, PowerShell and CIM | Leave a comment

DiskPart and PowerShell–part 1

An attendee at the Summit made the statement that the DiskPart utility didn’t have any equivalent in PowerShell. That’s not strictly true as the storage module provides a lot of functionality that maps to diskpart functionality. The module contents include: … Continue reading

Posted in CDXML, Powershell, PowerShell and CIM | Leave a comment

Name mismatch

Ever wondered why you can’t do this: Get-ADComputer -Filter * -SearchBase ‘OU=Servers,DC=Manticore,DC=org’ | Get-CimInstance -ClassName Win32_OperatingSystem The –ComputerName parameter on get-CimInstance accepts pipeline input BUT its by property name. PS> Get-Help Get-CimInstance -Parameter ComputerName -ComputerName [<String[]>]     Specifies computer on … Continue reading

Posted in PowerShell and Active Directory, PowerShell and CIM | Leave a comment

Get-SupportedFileSystems

I stumbled on the Get-SupportedFileSystems cmdlet today. Its part of the Storage module and is defined as a function. Digging a bit further its from a CDXML module based on a CIM class. But which CDXML file contains the definition? … Continue reading

Posted in CDXML, CIM, Powershell, PowerShell and CIM | Leave a comment

Finding DNS static records

An interesting question from the forums about finding DNS static records You can view the records in a DNS zone Get-CimInstance -Namespace root\MicrosoftDNS -ClassName MicrosoftDNs_Atype -ComputerName W16DC01  -Filter “DomainName = ‘manticore.org’” | select OwnerName, Timestamp, IPAddress but how do you … Continue reading

Posted in DNS, Powershell, PowerShell and CIM | Leave a comment

wmic deprecated

I saw a forum post today where the question involved the use of the wmi command line tool wmic. Wmic was deprecated in Windows Server 2012 – https://technet.microsoft.com/en-us/library/hh831568(v=ws.11).aspx. It will eventually be removed. You should use the CIM cmdlets instead … Continue reading

Posted in PowerShell and CIM, PowerShell and WMI | Leave a comment