Jump to content


Grover

Pulling OSDComputername into Powershell for Task Sequence

Recommended Posts

Hello Everyone,

 

I'm still fairly new to the OSD  task sequence portion for Imaging and Re-imaging in SCCM. 

I need help with the Powershell cmdlets on how to call/carry over the OSDComputername variable from a previous Task Sequence step, which I believe contains the  Computer name from reading the information in the BIOS,  over to the Powershell environment so that I can run  the following powershell commandline : remove-adgroup -identity "$computername-admin"

At my work,  some of the workstations have security groups named after their computername appended with the “-admin”  This is to keep track of members who require admin rights on otherwise locked down workstations.  We often have workstations being rotated where a PC may be re-assigned to another employee and I would like to automate inside a task sequence during a re-image to just delete any existing “Computername-admin” security group in AD so that we can start fresh. 

I hope my need for help makes sense.  If not please ask and I’ll try my best to explain further.   

 

Share this post


Link to post
Share on other sites

how about something simple like this...

 

$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$tsenv.Value("OSDComputerName") = $OSDComputerName

 

Share this post


Link to post
Share on other sites

I'm not infront of my computer but this can be inverted so that you can get or set $OSDComputerName

$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$tsenv.Value("OSDComputerName") = $OSDComputerName

I'll fire up my lab and show some examples shortly...

$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$OSDComputerName = $tsenv.Value("OSDComputerName")

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.