run command quietly start-process

This topic contains 5 replies, has 2 voices, and was last updated by  Shane Lindberg 2 years, 6 months ago.

  • Author
  • #32178

    Shane Lindberg

    I want to run the following command with powershell and wait till it completes before doing the next item

    slmgr.vbs -upk

    slmgr after it completes the command displays a windows which needs human intervention to click "ok" to close it and complete the process. I need this to work without human intervention. I figured out a way to do it using cscript , but it seems messy. Is there a way to do this without using cscript.

    This is the current working method, which seems good

    Start-Process "c:\windows\system32\cscript" "c:\windows\system32\slmgr.vbs -upk" -wait

    Is there a better way? I do need powershell 2.0 compatibility

  • #32182

    Flynn Bundy

    Hi Shane,

    If you're interested in possible other solutions I'd suggest you take a look into the WMI class for SoftwareLicensingService.

     Get-WmiObject SoftwarelicensingService 

    This class contains many methods that can mostly replace slmgr. Take a look into the members for the WMI class and see how you go.


  • #32184

    Shane Lindberg

    Thanks. That seems like a much better solution.

  • #32185

    Shane Lindberg

    there is an:

    I am having trouble finding documentation I can understand. I have tried the following with both methods.

    They say they take a string, so I am guessing it would be like this

    PS C:\Users\shane\Desktop> $a.InstallLicense('TOSINV00-TOSINV-2.1.XRM-MS')
    Exception calling "InstallLicense" : ""
    At line:1 char:1
    + $a.InstallLicense('TOSINV00-TOSINV-2.1.XRM-MS')
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : WMIMethodException

    If I am understanding the error it is the correct syntax but is is failing somewhere else. I am not sure if either of those are the methods I need, but can't see any others. Any suggestions would be appreciated,

  • #32186

    Flynn Bundy

    Hi Shane,

    As an example of adding a product key to a workstation you could use something like this:

    $x = Get-WmiObject SoftwarelicensingService

    Hopefully that helps.

  • #32187

    Shane Lindberg

    Thanks for the help. I am able to install the product key as you mentioned, but am having trouble installing the actual licence file

    This is the command I am trying to relplace and get away from slmgr.vba
    slmgr.vbs -ilc TOSINV00-TOSINV-2.1.XRM-MS

You must be logged in to reply to this topic.