Jump to content


dinci5

Device OU in report during OSD

Recommended Posts

Hi,

 

At the end of my OSD Task Sequence I run a Powershell script that generates a report and saves it in a certain location.

Helpdesk uses this report to quickly check if all applications are correctly installed and a few other things.

 

One of the things is a check for the OU of the device.

When I run the script from within Windows it works just fine.

However, during OS Deployment the OU cannot be read.

 

FYI...

The script does not rely on the ActiveDirectory modules. It uses the System.DirectoryServices namespace.

 

Any ideas how to get it to work?

Share this post


Link to post
Share on other sites

Well, i don't know what your script looks like, but this one should work.

$filter = "(&(objectCategory=computer)(objectClass=computer)(cn=$env:COMPUTERNAME))"
(([adsisearcher]$filter).FindOne().Properties.distinguishedname).replace('CN=' + $env:COMPUTERNAME + ',','')

Share this post


Link to post
Share on other sites

No, the System account should just work fine. It has the required permissions to read the object attributes from the AD.

One way to debug scripts in Task sequnces is to pause the sequnce. Have a look at Nialls Howto here https://www.windows-noob.com/forums/topic/8846-how-can-i-pause-a-task-sequence-in-system-center-2012-configuration-manager/

You can simply then run "powershell ise" from the F8 comman prompt and modify your script until it works as intended. This will save you countless hours of restarting sequences and watching progress bars.

Also make sure to dump the values of newly created variables in your script to the Standard Output, just to check if they hold the correct and expected value.

Share this post


Link to post
Share on other sites

No, the System account should just work fine. It has the required permissions to read the object attributes from the AD.

One way to debug scripts in Task sequnces is to pause the sequnce. Have a look at Nialls Howto here https://www.windows-noob.com/forums/topic/8846-how-can-i-pause-a-task-sequence-in-system-center-2012-configuration-manager/

You can simply then run "powershell ise" from the F8 comman prompt and modify your script until it works as intended. This will save you countless hours of restarting sequences and watching progress bars.

Also make sure to dump the values of newly created variables in your script to the Standard Output, just to check if they hold the correct and expected value.

Okey, that is seriously one of the best things there is to troubleshoot TS errors.

I will definitely try that one out.

Thanks a lot Peter!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.