Skip to content

Using Powershell to add Comp Desc

Featured Replies

Hello Windows-Noob Folks,

 

Followed this topic

 

https://www.windows-noob.com/forums/topic/11797-using-powershell-to-apply-task-sequence-variables/

 

To add the description in AD Computer. What I have done defined as below,

 

1. Created Powershell Script

#Create OSD Task Sequence Environment Object
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
#Get the ComputerDescription
$strComputerDesc = $tsenv.Value("OSDComputerDesc")
#Computer Name
$strName = $env:computername
#Get PSSession Credentials
$strUser = "domain\user"
$strPassword = "passw0rd"
#Connect to Remote PowerShell Session
#Set Active Directory Properties
$pw = ConvertTo-SecureString -AsPlainText -Force -String $strPassword
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "$strUser", $pw
$s = New-PSSession -Computer SERVER -Credential $cred
Invoke-Command -Session $s -Script { Import-Module ActiveDirectory }
Invoke-Command -Session $s -ScriptBlock { Set-ADComputer -Identity "$using:strname" -Description "$using:strComputerDesc" }
2. Created a Package (Not Program) and uploaded to DP
3. Now, How do I adds this in Task Sequence??
At first, I added as Run PowerShell Script but it won't worked out. :(
Second do I run as Run Command Line and add these line in TS
CMD.EXE /C %SYSTEMDRIVE%\windows\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -file .\ADpowershell.ps1
post-25316-0-46778300-1460460711.png
What is the preferred way to do this?
Thank you.

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.