Retrieve the WPSADM Password through BAT Script

Geo Thomas 1 Reputation point
2022-06-01T02:55:36.18+00:00

I used the below command in PowerShell to retrieve the WPSADM password of a computer.

@Jason Li .exe -Command "Get-QADComputer -proxy -SearchRoot "DC=domain,DC=com" -SearchScope Subtree -DontUseDefaultIncludedProperties -IncludedProperties name,ms-Mcs-AdmPwd "hostname" | select ms-Mcs-AdmPwd

But when converted the above to a batch script like below is not give any output and the Command window is getting closed.

set /p hostname=
for /f %%I in ('@Jason Li .exe -Command "Get-QADComputer -proxy -SearchRoot "DC=domain,DC=com" -SearchScope Subtree -DontUseDefaultIncludedProperties -IncludedProperties name,ms-Mcs-AdmPwd "%hostname%" | select ms-Mcs-AdmPwd"') do set "pwd=%%I"
setlocal EnableDelayedExpansion
echo %pwd%

The expected output of the script is: The WPSADM password of the %hostname% is: %pwd%

The above command will work only with Dell Active Roles. Could anyone help me to get the WPSADM Password through BAT Script?

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,628 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.