Support Forums

Active Directory Module

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.
User avatar
tirwin@iot.in.gov
Posts: 39
Joined: Mon Oct 19, 2015 5:45 am

Active Directory Module

Postby tirwin@iot.in.gov » Mon Jan 04, 2016 9:54 am

I have written a powershell script, an application that allow PC Refresh to set .Company, .DepartmentNumber, etc... On a ADOBject. In development everthing works fine. Obviously I have AD installed on my machine. I have compiled my app to a .exe and placed it on a network share where the techs will execute it from there as they start up a new computer or refresh from Windows 7 to Windows 10 mostly. The problem is the new pc will not have Active Directory installed at this point in time. I need to find a way to have my app import and run Active Directory as on start up of new or refreshed computers. How do I accomplish this? Below is some relivant code I use to import the module if it exist on the machine. Thanks


$RestoreForm_Load={
# Load the ActiveDirectory module if it's available
# Check if the ActiveDirectory module is installed
if ((Get-Module -ListAvailable | where { $_.Name -eq 'ActiveDirectory' }) -eq $null)
{
$labelDialogRedRestore.Text += "You need to install the ActiveDirectory module!`n"
}
else
{
# Check if the ActiveDirectory module is allready Imported
If ((Get-Module ActiveDirectory) -eq $null)
{
Import-Module ActiveDirectory -ErrorAction 'SilentlyContinue'
$labelDialogGreenRestore.Text += "ActiveDirectory module imported`n"
}
else
{
$labelDialogGreenRestore.Text += "ActiveDirectory allready imported`n"
}
}
User avatar
jvierra
Posts: 9693
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Active Directory Module

Postby jvierra » Mon Jan 04, 2016 10:24 am

You can't. You must install RSAT on every PC that needs to run your form.
User avatar
jvierra
Posts: 9693
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Active Directory Module

Postby jvierra » Mon Jan 04, 2016 10:32 am

Note that, if you have remoting configured, you can use Invoke-Command to a DC to run the AD commands.
User avatar
jlawatts
Posts: 5
Joined: Tue Apr 09, 2013 1:35 am

Re: Active Directory Module

Postby jlawatts » Tue Jan 05, 2016 9:07 am

Hi,
If you're just talking about updating the attributes of the AD object, have you thought about doing it without needing to use the ActiveDirectory module?
So for example, using ADSI just to update the description of a computer...

$Computer = [ADSI]"LDAP://CN=LNDT0002D,OU=Computers,OU=London,OU=EMEA,OU=Herbert Smith,DC=herbertsmith,DC=dev"
$Computer.Put("description","bob")
$Computer.SetInfo()

I know that in this example, you already know the distinguished name of the computer, but you could easily use ADSI to find and create the computer object, which you then update as above.
User avatar
jvierra
Posts: 9693
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Active Directory Module

Postby jvierra » Tue Jan 05, 2016 9:20 am

While ADSI allows us to access all of AD it also requires that you are a very proficient programmer and very well trained in AD/LDAP.
Here is a form I wrote some years ago to use ADSI to update AD.

This first file shows how to set up and access AD from Form using ADSI: Demo-AddUserFrom.psf

This one shows how to do updates: Demo-ADUpdate.psf

This one shows how to navigate: Demo-ADSITreeView.psf

And finally here is how to remote a form: Demo-ADRemoteForm.psf
Attachments
Demo-ADRemoteForm.psf
And finally here is how to remote a form
(32.97 KiB) Downloaded 140 times
Demo-ADSITreeView.psf
This one shows how to navigate
(15.56 KiB) Downloaded 140 times
Demo-ADUpdateForm.psf
This one shows how to do updates
(27.23 KiB) Downloaded 139 times
Demo-ADAddUserForm.psf
This first file shows how to set up and access AD from Form using ADSI
(43.63 KiB) Downloaded 145 times
User avatar
hnoor0033
Posts: 1
Joined: Mon Feb 01, 2016 2:30 am

Re: Active Directory Module

Postby hnoor0033 » Mon Feb 01, 2016 2:43 am

If you're just talking about updating the attributes of the AD object, have you thought about doing it without needing to use the ActiveDirectory module?


______________
NOOR
User avatar
weiyen.tan@gmail.com
Posts: 52
Joined: Wed Apr 09, 2014 2:06 am

Re: Active Directory Module

Postby weiyen.tan@gmail.com » Sat Feb 27, 2016 1:54 am

An example of implicit remoting by using invoke-command can be found https://technet.microsoft.com/en-us/magazine/ff720181.aspx .

Return to “Windows PowerShell”

Who is online

Users browsing this forum: No registered users and 3 guests