Skip to content

Device OU in report during OSD

Featured Replies

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?

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 + ',','')

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.

  • 2 weeks later...
  • Author

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!

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...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.