0

We have a batch file that certain users can launch from their local machines that will run a PowerShell script on a DC in order to unlock user accounts or reset a password. However, all of a sudden it's not working, not even for network admins running it as an administrator. If we log on to the DC and run it locally, it works exactly as it should.

There haven't been any changes to the permissions of the file and no changes to the AD groups that have permission to run the file.

The batch file is this:

@echo off
cls
echo Loading, Please Wait...
;C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe -ExecutionPolicy Bypass -File %logonserver%\<PATH TO FILE>\FILENAME.ps1

Same batch file that it's always been, but now when we run it remotely, we get multiple errors:

The term 'Get-ADGroupMember' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Locally, it runs just fine. And yes, the first thing the PowerShell script does is

Import-Module ActiveDirectory -ErrorAction SilentlyContinue

As I said, it used to work but now it doesn't and we're completely lost as to why. We've searched and searched, but can't seem to find any information as to what might be causing it to error out.

If anyone has any ideas or suggestions, we would appreciate it.

5
  • 1
    Hi, The first question you ask in this type of situation is, what was the most recent change? Not necessarily to the script, but maybe to the client OS. You say it doesn't work remotely, how many different remote systems have you tried? If you run the script in PowerShell without involving cmd.exe, what happens? Commented Jan 3, 2023 at 16:07
  • 5
    It sounds like the Import-Module call is (now) failing. Remove -ErrorAction SilentlyContinue from it to see any error messages. Note that using -ErrorAction SilentlyContinue with Import-Module generally doesn't make much sense. Commented Jan 3, 2023 at 16:21
  • 1
    @mklement0 It's possible the developer thought that would suppress the progress bar, but if course it doesn't work that way. Commented Jan 3, 2023 at 21:03
  • 1
    It does appear the Import-Module isn't working anymore, so I'm not sure what happened there. I appreciate the input. And yeah, not sure why some things are the way they are in the script; I inherited it from the guy that had this job before me. Commented Jan 4, 2023 at 14:27
  • As a follow-up: discovered that RSAT wasn't on any of the machines anymore. It required downloading the installer and running it on the machines. Once we did that, everything works like it should. Appreciate folks helping out with this. Commented Jan 4, 2023 at 17:32

1 Answer 1

1

Discovered that RSAT wasn't on any of the machines anymore. It required downloading the installer and running it on the machines. Once we did that, everything works like it should.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.