Categories

Just a thought

I’ve working with WMI a lot recently and frequently seen things like this

Get-WmiObject -Class Win32_OperatingSystem -ComputerName dc02

Get-WmiObject -Class Win32_ComputerSystem -ComputerName dc02

Get-WmiObject -Class Win32_LogicalDisk -ComputerName dc02

Each of these has to create a connection

is

$sb = {
Get-WmiObject -Class Win32_OperatingSystem
Get-WmiObject -Class Win32_ComputerSystem
Get-WmiObject -Class Win32_LogicalDisk
}

Invoke-Command -ScriptBlock $sb -ComputerName dc02

more efficient

In some cases yes depending on what you want to do with the information. Especially if need to filter data

4 Responses to Just a thought

  • Jason says:

    Good method. But it requires WS-Management service running on the destination. On older servers it might be an issue.

  • RichardSiddaway says:

    Yes it does but it can be installed on Windows 2003 and above.

    Windows 2000 isn’t really an issue – its a year out of support and should be on the way out of the organisation if it hasn’t gone already.

  • Jason says:

    OT: for Windows 2000 boxes: it was easy to get rid of them when they were on the physical boxes – scheduled hw refresh would take care of it. But now after p2v’ed them, nobody bothers to touch them – the “if it ain’t broken, don’t fix it” mantality :(

  • RichardSiddaway says:

    Agreed – I know of people still finishing off NT4 removal – but they do leave a security hole and have to go eventually

Leave a Reply