Jump to content




Sign in to follow this  
Danie

Using Powershell to add Comp Desc



Recommended Posts

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.

Share this post


Link to post
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


×