Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
evil_bunnY
Apr 2, 2003

adaz posted:

Bumping this thread in case there are any more questions and the scripting guys have been running a great series on powershell & active directory this week that everyone should check out:

http://www.games-workshop.com/gws/catalog/productDetail.jsp?catId=cat440342a&prodId=prod840005a
I don't think that's what you meant to post, buddy!

Adbot
ADBOT LOVES YOU

evil_bunnY
Apr 2, 2003

This is awesome: you map a share from a normal shell: can't use your admin token. You map it from an elevated shell: can't loving resolve. What the gently caress do you want from me.
e: works after restarting the shell. Urgh.

Also, any program that can create 260+ chars paths needs to die in a fire. HAHA you can look at it, but you can't touch it!

Long story short, I'm now writing a script that recursively renames to shortest possible name + takes ownership (in which order? both!) and deletes anything still alive. gently caress you, NTFS.

evil_bunnY fucked around with this message at 10:35 on Oct 11, 2011

evil_bunnY
Apr 2, 2003

Serfer posted:

See also subst.
it's what I ended up using. It's such a crappy system though.

evil_bunnY
Apr 2, 2003

psylent posted:

I'm incredibly new to Powershell, as a senior helpdesk monkey I can see how it's going to be incredibly helpful.

I've got a shitload of user accounts (100+) of people that have left the company that I need to clean up/archive. My first step is to move them all into a "To be Terminated" OU. I then need to remove them from all Security/Distribution lists (except Domain Users) - this is where Powershell will come in handy as I'd prefer to run a quick script rather than go into each user and remove the groups manually!


An easier way to do this is to define deny rights on your filesystems and just plop them in that group when they leave (after disabling the account). More work beforehand, but very simple day-to-day.

evil_bunnY
Apr 2, 2003

Get-ChildItem, if I see you around I'm going to beat your rear end to a pulp. That is all.

evil_bunnY fucked around with this message at 21:56 on Dec 12, 2012

evil_bunnY
Apr 2, 2003

It would be trivial to make a CLI script user-friendly instead.

evil_bunnY
Apr 2, 2003

code:
#load CLI args (This should be a filename) into array
$a = (get-content groups.txt)
#get list of users, show account and display name
ForEach-Object ($user in $a) {Get-ADGroupMember -Identity $user | get-aduser -properties * | select SamAccountName, displayname}
code:
PS C:\scripts> .\Get-ADGroupUserList.ps1 groups.txt
At C:\scripts\Get-ADGroupUserList.ps1:4 char:23
+ ForEach-Object ($user in $a) {Get-ADGroupMember -Identity $user | get-aduser -pr ...
+                       ~~
Unexpected token 'in' in expression or statement.
At C:\scripts\Get-ADGroupUserList.ps1:4 char:22
+ ForEach-Object ($user in $a) {Get-ADGroupMember -Identity $user | get-aduser -pr ...
+                      ~
Missing closing ')' in expression.
At C:\scripts\Get-ADGroupUserList.ps1:4 char:28
+ ForEach-Object ($user in $a) {Get-ADGroupMember -Identity $user | get-aduser -pr ...
+                            ~
Unexpected token ')' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : UnexpectedToken
Is it not reading the file to an array? File's just group names on each line.

Adbot
ADBOT LOVES YOU

evil_bunnY
Apr 2, 2003

Just /MIR it and log to a file.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply