Avatar of Shabarinath TR
Shabarinath TR
Flag for India asked on

Execute exe / register DLL remotely using Invoke-Command

Dear Experts!

I am trying to automate a recurring task using a powershell script.

As per of the requirement, I have the below two situations.

1) Register a dll. DLL file exists locally. Regsrv32 is the only option available. But I am not sure if regsrv32 with /s switch (silent) will be the right option. Or is there any PowerShell alternate? Also, Once registered, Is there a way for me to check if the dll was registered successfully?

2) Execute an exe. This is basically for fixing something with the SCCM site code. ccmsetup.exe is located on the local directory and I am able to execute the entire command locally, which will fix. But thats not working if I am trying to use it remotely along with invoke-command.

Appreciate any help or guidance on this.

Cheers !


Avatar of undefined
Last Comment
Hayes Jupe

8/22/2022 - Mon
Hayes Jupe

1) im not aware of a powershell equivalent, i don't believe there is one.
As far as checking for registration, you can use https://www.nirsoft.net/utils/registered_dll_view.html to easily find the associated class registry entry - and then check for that as part of your script.
Here is an example script that looks for the name instead of checking for the exact CSLID (which the above would give you - and be more efficient)  - https://powershelladministrator.com/2019/12/17/register-dll-or-ocx-files-check-result/

2) I'd love to know what you have done to need to do this.
Anyway, make your life simple and use psexec within a for loop (batch vbs or powershell - whichever language you prefer) to target all the affected systems... or, since its the SCCM client, you could just re-push the client with the correct parameters (or use a start up script)
The only scenario i can think of where you would ever need to do anything manually to a site code is in a hierarchy migration that was not done well.

Shabarinath TR

Hi Hayes,

Thanks. I was looking for a PowerShell equivalent so that its easy to add within my existing PowerShell script.

On point number 2, This is specific to a validation we are doing after provisioning happens. Sometimes, the server for production environment is getting connected with the dev sccm instance. So we need to fix by running ccmsetup.exe pointing to the right sccm server. I am using the below piece of code.

 invoke-Command -Computername servername -scriptblock {Start-Process -FilePath 'C:\Windows\SCCM\ccmsetup.exe' -ArgumentList '/mp:MP01'}

Cheers !
Hayes Jupe

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy