Register
: :
Login
Home
News
Forums
Scripts
User Groups
Resources
About
Forums
Search
Members
Unanswered
Active Topics
Forums
>
Using PowerShell
>
Active Directory
Concatenating sting to a attribute
Last Post 12 Jan 2010 07:21 AM by
cameronove
. 4 Replies.
Sort:
Oldest First
Most Recent First
Prev
Next
You are not authorized to post a reply.
Author
Messages
Datacom
New Member
Posts:27
06 Jan 2010 09:12 PM
Hi Guys,
How do concatenate (say xxx) to samid for all the disabled users using quest cmdlets. E.g
I want to search for a samaccountname "AB" and disable it and and add "xxx" as prefix to the samaccoutname (samaccountname should be like xxxAB)
Any help will be much appreciated. Thanks
Regards
Shay Levy
PowerShell MVP, Admin
Veteran Member
Posts:1362
06 Jan 2010 11:39 PM
Try this:
Get-QADUser -SamAccountName AB | ForEach-Object { Set-QADUser $_ -SamAccountName ($_.SamAccountName+'AB') }
Shay Levy
Windows PowerShell MVP
http://PowerShay.com
PowerShell Community Toolbar
Twitter:
@ShayLevy
Datacom
New Member
Posts:27
07 Jan 2010 09:18 PM
Thx Shay. Works perfectly fine.Have couple of more questions. How do i pass mulitple arguments in the same query. Eg In the above query we searched for a name and appended the string. Now i want to add xxx in the description and set the expiry date to todays date.
My quesstion is can i do it in the same query using AND. If you can explain with the above example that will be highly appreciated. Thanks Shay.
Shay Levy
PowerShell MVP, Admin
Veteran Member
Posts:1362
11 Jan 2010 08:53 AM
Get-QADUser -SamAccountName AB | ForEach-Object {
Set-QADUser $_ -SamAccountName ($_.SamAccountName+'AB') -Description ($_.Description+"xxx") -AccountExpires (Get-Date)
}
Shay Levy
Windows PowerShell MVP
http://PowerShay.com
PowerShell Community Toolbar
Twitter:
@ShayLevy
cameronove
Basic Member
Posts:332
12 Jan 2010 07:21 AM
Try this alternative...
get-qaduser -ldapfilter '(samaccountname=ab)' | %{$_.samaccountname = "xxx$($_.samaccountname)";$_.description = "xxx$($_.description)";$_.accountexpires = (Get-Date);$_.commitchanges()}
You are not authorized to post a reply.
Using PowerShell
--General PowerShell
--Books, Tools, and Videos
--Exchange Server
--Active Directory
--System Center Family
--Non-Microsoft Products
--SharePoint
--SQL Server
--Working with .NET
--Peer Review
--Testing, Testing...
PowerShell Development
--Cmdlet Development
--PSDrive Provider Development
--Hosting the Shell
Looking Ahead
--Using PowerShell v2.0
--Developing for PowerShell v2.0
PowerShellCommunity.org
--Community Announcements and Assistance
--Completely Unrelated
--User Groups
--Community Business
----Suggestion Box
Forums
>
Using PowerShell
>
Active Directory
Active Forums 4.3
Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2