JoeParticipantJanuary 22, 2018 at 4:40 pmPost count: 5
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.
RichardParticipantJanuary 22, 2018 at 5:50 pmPost count: 2
Do you have the RSAT tools installed on the client device(s) so that when the Import-Module ActiveDirectory cmdlet is called, it can locate the required contents?
RichardParticipantJanuary 22, 2018 at 8:27 pmPost count: 2
Hi Joe, the Get-AD* cmdlets are not available unless the RSAT tools are installed.
Since you want to query AD from multiple client PC’s, RSAT needs to be installed on those systems in order to have access to the Get-ADComputer cmdlet.
Your statement “Dont think its good practice install admin tools for standard uses.” is correct and I agree, but you are attempting to perform an admin related task from a client PC therefore requiring the RSAT tools and associated PowerShell cmdlets.
Perhaps you need to redesign the solution in order to make this work?
What deployment method are you using?
Think about checking if clients meet certain criteria and then targeting them with a software deployment. This approach is essentially how deploying software to a collection of computers works in SCCM.
JoeParticipantJanuary 23, 2018 at 6:54 amPost count: 5
Yes you are right. I can always uninstall RSAT at the end of the script if needed anyway.
I cant think of another way to obtain the Distinguished name of a machine and then query it at a later stage so will include it in this script and the forum know the outcome.
I am using SCCM 2012 to deploy the PSAD script. I could have 20 different deployments for each targeted site but the 20 sites will increase and SCCM will get messy. Each ‘site’ has a specific configuration and a certificate to go with it so my script queries the computer and depending what OU they are in they get said config.
JoeParticipantJanuary 29, 2018 at 11:43 amPost count: 5
I have found that you will need to install RSAT on the client machine in order for the “Get-AdComputer” cmdlet to work. Below is what I used to obtain the information needed using WMI.
<code> $cname = $env:Computername $OU = ([adsisearcher]"(&(name=$env:computername)(objectClass=computer))").findall().path $OU = $OU -Replace "LDAP://" $distname = $OU</code>
using ([adsisearcher]”(&(name=$env:computername)(objectClass=computer))”).findall().path outputs the command with LDAP:// at the beginning so I used POSH to replace the “LDAP://” and set that as a variable.
You must be logged in to reply to this topic.