Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 8 years and 4 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
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"
}
}
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...
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.
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
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?
This topic is 8 years and 4 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.