WMI Query Script as a Job

后端 未结 3 925
刺人心
刺人心 2021-01-16 06:16

I have two scripts. One calls the other with a list of servers as parameters. The second query is designed to execute a WMI query. When I run it manually, it does this perfe

相关标签:
3条回答
  • 2021-01-16 06:27

    This is one instance I could find. http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/a6c816dd-2c2c-47bc-a2d0-238fbb9d66a6

    There are many other discussions I have seen around the same.

    Anyway, to make sure your WMI respository isn't corrupt, just try re-compiling it. Put the following lines in a batch file and run:

    net stop winmgmt
    c:
    cd c:\windows\system32\wbem
    rd /S /Q repository
    regsvr32 /s %systemroot%\system32\scecli.dll
    regsvr32 /s %systemroot%\system32\userenv.dll
    mofcomp cimwin32.mof
    mofcomp cimwin32.mfl
    mofcomp rsop.mof
    mofcomp rsop.mfl
    for /f %%s in ('dir /b /s *.dll') do regsvr32 /s %%s
    for /f %%s in ('dir /b *.mof') do mofcomp %%s
    for /f %%s in ('dir /b *.mfl') do mofcomp %%s
    mofcomp exwmi.mof
    mofcomp -n:root\cimv2\applications\exchange wbemcons.mof
    mofcomp -n:root\cimv2\applications\exchange smtpcons.mof
    mofcomp exmgmt.mof
    
    0 讨论(0)
  • 2021-01-16 06:28

    Do yourself a favor and check WinRM. If remoting is turned off, you'll experience this exact set of symptoms.

    Can *.ps1 scripts run as background jobs themselves execute *.ps1 scripts?

    How do I debug a PowerShell background job?

    0 讨论(0)
  • 2021-01-16 06:37

    Your script worked fine for me with the write credentials, but blocked when the credentials were wrong.

    0 讨论(0)
提交回复
热议问题