Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

WMI Remote Repair

$
0
0

Hello,

I'm looking to write a script to remotely repair WMI.

So far this is what I have.

Invoke-Command -Computername $PC -scriptblock {net stop winmgmt /y}

Invoke-command -Computername $PC -scriptblock {regsvr32 $env:systemroot\system32\scecli.dll}

Invoke-command -Computername $PC -scriptblock {regsvr32 $env:systemroot\system32\userenv.dll}

$AllDll = get-childitem -path \\$PC\C$\Windows\System32\wbem -recurse -include *.dll

foreach($dll in $AllDll){

invoke-command -Computername $PC -scriptblock {regsvr32 /s $dll}

}

$AllMofmfl = get-childitem -path \\$PC\C$\Windows\System32\wbem -recurse -include *.mof,*.mfl

foreach($item in $AllMofmfl){

invoke-command -computername $PC -scriptblock {mofcomp $item}

}

or would it be easier to only call one invoke-command with everything in the script block?

Thanks for your help


Viewing all articles
Browse latest Browse all 6937

Trending Articles