I am writing a PSAD script to detect the remote computers OU and that will then install the software and configuration for that site.
My problem is is that It is running the script perfectly on my (admin) maachine but not on a pilot users machine.
I have checked the C:\Windows\Logs\Software log files and getting the below.
[Post-Installation] :: Error Record:
Message : The term ‘get-adcomputer’ 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.
I have added Import-Module ActiveDirectory at the top but it still doesnt work. does anyone have any thoughts to why? Below is the script.
<code> Import-Module ActiveDirectory $cname = $env:Computername $distname = Get-Adcomputer $cname | Select Name -ExpandProperty DistinguishedName</code>
From the code above I then set a variable for the Distinguished name, then I have IF statements to run through 20 OU variables and then If that computer matches one of the 20 it’ll have the specific configuration.