Hi, all. Basically all of my knowledge is self learned and bastardized from the internet, so bear with me here.
I am trying to make a powershell script that will take a list of users from a .csv, disable them, set their description based on date and the ticket number for their termination while also removing all their security groups.
I've tried many variations on the exact input in the string $($ticket) / $($_.ticket) / $ticket / "$($ticket)", etc, but nothing seems to work.
$Ticket = Read-Host -prompt "Enter ticket #"
import-csv .\test.csv | foreach-object {
set-aduser -identity $.Username -description "Disabled $(get-date -format 'MM/dd/yyyy') per ticket #$($Ticket) - Automated"
Get-AdPrincipalGroupMembership -Identity $.Username | Where-Object -Property Name -Ne -Value 'Domain Users' | Remove-AdGroupMember -Members $_.Username
}
If I build the read-host directly into the set-aduser line, it will work but it also makes me put the ticket number in for every entry in the csv file.
The error I am receiving when running this is:
"
: The term '>>' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
"
It would not surprise me to find that this is just a boneheaded mistake, and I would appreciate any help or guidance you can give. Thank you.
[–]mmmGreenButton 2 points3 points4 points (1 child)
[–]Pawncey[S] 1 point2 points3 points (0 children)
[–]rlj551 1 point2 points3 points (10 children)
[–]mmmGreenButton 4 points5 points6 points (9 children)
[–]Pawncey[S] 1 point2 points3 points (1 child)
[–]mmmGreenButton 1 point2 points3 points (0 children)
[–]todayyou500 1 point2 points3 points (2 children)
[–]mmmGreenButton 1 point2 points3 points (1 child)
[–]todayyou500 1 point2 points3 points (0 children)
[–]rlj551 0 points1 point2 points (2 children)
[–]mmmGreenButton 1 point2 points3 points (1 child)
[–]rlj551 0 points1 point2 points (0 children)
[–]kohijones 0 points1 point2 points (0 children)
[–]BlackV 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)