This topic contains 5 replies, has 2 voices, and was last updated by
November 22, 2015 at 12:50 pm #32178
I want to run the following command with powershell and wait till it completes before doing the next item
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
November 22, 2015 at 3:24 pm #32182ParticipantPoints: 0Rank: Member
If you're interested in possible other solutions I'd suggest you take a look into the WMI class for 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.
November 22, 2015 at 4:07 pm #32184
Thanks. That seems like a much better solution.
November 22, 2015 at 5:25 pm #32185
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,
November 22, 2015 at 8:38 pm #32186ParticipantPoints: 0Rank: Member
As an example of adding a product key to a workstation you could use something like this:
$x = Get-WmiObject SoftwarelicensingService $x.InstallProductKey('XXXXX-XXXXX-XXXXX-XXXXX-XXXX') $x.RefreshLicenseStatus()
Hopefully that helps.
November 22, 2015 at 8:46 pm #32187
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
The topic ‘run command quietly start-process’ is closed to new replies.