|
FISHMANPET posted:Nevermind what a loving task it was to get powershell to even search. And nevermind how impossible Microsoft has made it to actually get the AD cmdlets. Why in the hell would I have to run a special instance of Powershell (Active Directory Module for Windows PowerShell) to actually be able to query AD. Shouldn't running Powershell on the DC be enough? FISHMANPET posted:So I say to myself, this sounds perfect for Powershell! Except Powershell can't read the profile paths out of most of my accounts, they just show up as null. dsget works just fine, and looking at them in AD Users & Computers I see the bad profile path, but get-aduser shows nothing.
|
# ? Aug 16, 2012 12:35 |
|
|
# ? May 15, 2024 01:44 |
|
Misogynist posted:Import-Module ActiveDirectory That would have been just fine, except for a lot of the accounts the ProfilePath was listed as empty.
|
# ? Aug 16, 2012 16:17 |
|
So I may very well be using the Powershell ISE for the wrong thing, but I'm trying to use it as a replacement for the regular command prompt. No real reason other than I think it looks nicer. However, when trying to do some ruby on rails stuff, I noticed I can't get the "rails console" command to work. It starts the console, but the irb never pops up and I'm forced to terminate the ruby.exe instance that's launched before I can send any more commands through the ISE. Is the ISE unable to work with interactive programs being launched from inside of it?
|
# ? Aug 23, 2012 19:44 |
|
PhonyMcRingRing posted:So I may very well be using the Powershell ISE for the wrong thing, but I'm trying to use it as a replacement for the regular command prompt. No real reason other than I think it looks nicer. However, when trying to do some ruby on rails stuff, I noticed I can't get the "rails console" command to work. It starts the console, but the irb never pops up and I'm forced to terminate the ruby.exe instance that's launched before I can send any more commands through the ISE. Is the ISE unable to work with interactive programs being launched from inside of it? The ISE runs in STA mode, if Ruby on Rails is requiring MTA then that could be it. I'm not familiar at all with the ruby tools to say for sure. I've launched interactive programs from inside the ISE before (usually winform type stuff from a powershell script).
|
# ? Aug 24, 2012 03:41 |
I've got a couple of projects that were given that require a list of Windows servers, their current OS (2k3, 2k3 R2, 2k8, 2k8R2, etc.) and their current Description field in AD. I've seen how to use dsquery to get a list on a per-OU basis, but optimally what I'd like is a script that queries AD for any machine and outputs its name, Description field, and server OS. I am not allowed to use the Quest AD cmdlets, which seems to be the solution that everyone who doesn't work for my company goes for. I've already tried to convince the powers that be that it really won't do any harm, especially if all I'm running is a query, but it took enough convincing for me to let Powershell be used. Any way I can make this happen?
|
|
# ? Aug 24, 2012 13:35 |
|
MJP posted:I've got a couple of projects that were given that require a list of Windows servers, their current OS (2k3, 2k3 R2, 2k8, 2k8R2, etc.) and their current Description field in AD. I've seen how to use dsquery to get a list on a per-OU basis, but optimally what I'd like is a script that queries AD for any machine and outputs its name, Description field, and server OS. Quest AD cmd-lets are crutches and yes it's not too hard using the base .NET classes in DirectoryServices code:
adaz fucked around with this message at 15:48 on Aug 24, 2012 |
# ? Aug 24, 2012 15:44 |
|
I am writing a script to automate the generation of VMs in VMM2012 and I'm at a loss with an error I'm getting. Here's the part that's causing issues:code:
code:
edit: Yep, it was really that simple. Changed it to code:
vanity slug fucked around with this message at 15:05 on Aug 30, 2012 |
# ? Aug 30, 2012 09:35 |
|
I need to set a HTML signature for a stack of OWA users. I grabbed this script from the webcode:
The reason being I have 1000 mailboxes but only 500 OWA users, and I only know who they are based on whether they have a sig file in the folder. Edit: Did it all by myself! Look at me go! code:
Swink fucked around with this message at 07:03 on Sep 4, 2012 |
# ? Sep 4, 2012 03:15 |
|
:facepalm: So for the long time was trying to get a powershell script that (simply) let me know if the current day was the first weekday of the month. For mailing purposes I send an email based on whether or not that is true code:
|
# ? Sep 5, 2012 21:17 |
|
Wicaeed posted::facepalm:
So you can cut it down to this: code:
Vulture Culture fucked around with this message at 00:15 on Sep 6, 2012 |
# ? Sep 6, 2012 00:10 |
|
Powershell 3.0 is now available officially for download (win 7, win2008, win2k8 R2 and above). http://blogs.technet.com/b/heyscriptingguy/archive/2012/09/06/powershell-3-0-is-now-available-for-download.aspx Highly recommended, the intellisense in the IDE alone is worth it
|
# ? Sep 6, 2012 07:09 |
|
Never mind!
Swink fucked around with this message at 12:33 on Sep 11, 2012 |
# ? Sep 11, 2012 11:48 |
|
Am I going about things in entirely the wrong way, or is handling HTTP requests a very cumbersome process in Powershell? For instance, if I wanted to get google's homepage, I could do something like this:code:
|
# ? Sep 19, 2012 01:24 |
|
stubblyhead posted:Am I going about things in entirely the wrong way, or is handling HTTP requests a very cumbersome process in Powershell? For instance, if I wanted to get google's homepage, I could do something like this: That's pretty much the way it goes in PowerShell v2, in v3 you can use Invoke-WebRequest http://www.google.com
|
# ? Sep 19, 2012 10:02 |
|
kampy posted:That's pretty much the way it goes in PowerShell v2, in v3 you can use Invoke-WebRequest http://www.google.com Good thing I'm using PS 3.0! This is about 1000% simpler, thanks for the tip!
|
# ? Sep 19, 2012 17:12 |
|
I have a situation where I need to write a script that will look at three pieces of information in order to add them to certain corresponding mail groups. Normally this would not be difficult. However, the third piece of information is a combination of the first two. So it's like a Venn Diagram: Location = Location Mail Group Location + Role = Location Role Mail Group Role = Role Mail Group For Location and Role I wrote: code:
In other words, I want a short version of: code:
-Brian
|
# ? Sep 19, 2012 21:01 |
|
There are a bunch of more elegant ways of doing this (SQL y'all) but based on what you described here you go. You create a typed object and run where-Object queries off that? I assume role is also entered by the users.. I.e. code:
adaz fucked around with this message at 03:25 on Sep 20, 2012 |
# ? Sep 20, 2012 03:23 |
|
Anyone else getting a shitload of yellow warning errors with 3.0? I'm getting them with every command. Although it might be the exchange2010 snapin I'm using. Also, half of the commands dont have a help entry, and update-help doesnt work. Running as Admin or otherwise.
|
# ? Sep 21, 2012 07:54 |
|
Swink posted:Anyone else getting a shitload of yellow warning errors with 3.0? I'm getting them with every command. Although it might be the exchange2010 snapin I'm using. I haven't had any problems with warnings myself. I have had some issues with Get-Help though, mostly that it wants to download updates to it frequently. It hasn't done it for a while though, but when I first installed it it would try the first time I'd use it in a session.
|
# ? Sep 21, 2012 16:27 |
A request came in to create a distro based on user names alone. That was done. Now the requestor wants a list of the email addresses of the users as well. I'm using Exchange 2007 shell and get-distributiongroupmember -identity "groupname" | fl PrimarySMTPAddress lists the addresses, but is there any way to also list the name and then I can just > nameslist.csv it to him? Edit: bada bing. get-distributiongroupmember -identity "groupname" | format-table Name,PrimarySMTPaddress > nameslist.csv did the trick and some text to columns made it legible. MJP fucked around with this message at 16:47 on Sep 27, 2012 |
|
# ? Sep 27, 2012 16:25 |
|
MJP posted:Edit: bada bing. get-distributiongroupmember -identity "groupname" | format-table Name,PrimarySMTPaddress > nameslist.csv did the trick and some text to columns made it legible. I don't have the exchange cmdlets installed, but you might want to consider using select and Export-Csv there instead of format-table, something like this should work: code:
|
# ? Sep 28, 2012 20:17 |
|
kampy posted:I don't have the exchange cmdlets installed, but you might want to consider using select and Export-Csv there instead of format-table, something like this should work: Yeah, Import-csv is a POS, but export works pretty well. You don't need to do that sort of redirection in powershell.
|
# ? Sep 30, 2012 07:18 |
|
So here's my situation, goons: We have a .NET application hosted on our web server that does read only access to an old legacy UniVerse file store. Whenever the connection times out or the Application Pool resets, the first access to the file store is inordinately slow. What I'd like to do is script a dummy "search" and run it on the server 3-5 minutes before open of business each day. The search is done using an AJAX POST method with a JSON object that is determined by the text in a text box. If I just wanted to simulate that, would it be possible from a powershell standpoint?
|
# ? Oct 3, 2012 20:31 |
So what I'm trying to do is develop a Powershell script that I'd run as a daily scheduled task. We have three Citrix servers where individual user profiles get created. What I want to do is tell Powershell to run the delprof2 command with the arguements specified (one script per server), say Y to start the process, then wait for it to ask "Delete profile X?" Some profiles should never get deleted. It should say N to those. For everything else, it should say Y. I have her X being what I think is the list of users to say N to. The $y line is what the command comes back with where I need it to say Y to start the process. After that it'll spit out a list of names and say "Delete profile 'profilelocation'" which waits for a Y or N. I redacted out any potentially identifying info, so for the purposes of what you see, administrator, jdoe, and Citrix are the accounts that should always get an N. code:
|
|
# ? Oct 24, 2012 16:45 |
|
Does anybody else docode:
(Also Consolas for life.)
|
# ? Nov 7, 2012 21:31 |
|
I cooked up a script to generate a list of AD account names, based off an HR-provided list of full names. I figure I'll throw it in here and see if anyone has a better / more effective way of doing this. Basically I'm trying to account for the special snowflakes whose account name can't be easily guessed from their first initial and last name (our standard convention). This script still has issues with things like nicknames (HR has them on file as Elizabeth, their AD GivenName is Beth), people with complicated last names ("Van Buren"), etc. Seems to get about 98% of our users correctly, but accounting for the last 2% is a pain. code:
|
# ? Nov 7, 2012 22:38 |
|
Why not search the GivenName and Lname attributes directly? LDAP search like "(&(fname=$fname)(sn=$lname))" etc? Are there any other key fields you can search on, like some companies will enter employeeID into the fields, or have a sane and rational email address schema you can search on. Like ours is always first.last@domain.gov, or first.mi.last@domain.gov and we only allow - as special characters in the email. So that can usually get 99+% of users, there are always the few special folks who have to be manually found.
|
# ? Nov 8, 2012 01:18 |
|
adaz posted:Why not search the GivenName and Lname attributes directly? LDAP search like "(&(fname=$fname)(sn=$lname))" etc? Are there any other key fields you can search on, like some companies will enter employeeID into the fields, or have a sane and rational email address schema you can search on. I do do that, that's the second get-aduser I try. We still run into problems with people like Elizabeth vs. Beth, though. I guess that's the main problem, if we forced AD accounts to always be the legal names HR keeps on file we'd be a lot better off.
|
# ? Nov 8, 2012 02:29 |
|
Mierdaan posted:I do do that, that's the second get-aduser I try. We still run into problems with people like Elizabeth vs. Beth, though. I guess that's the main problem, if we forced AD accounts to always be the legal names HR keeps on file we'd be a lot better off. Yeah there's not really a programming solution here other than use gname and fname attributes in AD to put in their given name and use fname to put in their "preferred" name. Or tie the accounts back to HR if you folks use employee number or something other UID
|
# ? Nov 8, 2012 06:18 |
|
adaz posted:Yeah there's not really a programming solution here other than use gname and fname attributes in AD to put in their given name and use fname to put in their "preferred" name. Or tie the accounts back to HR if you folks use employee number or something other UID Thanks, employee ID might work for us.
|
# ? Nov 8, 2012 13:26 |
MJP posted:So what I'm trying to do is develop a Powershell script that I'd run as a daily scheduled task. We have three Citrix servers where individual user profiles get created. Figured I'd re-inquire... anyone?
|
|
# ? Nov 12, 2012 19:00 |
|
Does anyone know how to find the file associated with the function currently loaded into memory? For example let's say I load a function: ***begin*** cd D:\scripts .\renameserver.ps1 Rename-Computer $name $creds ***end*** Is there any way to find the source file that Rename-Computer was loaded from? I've been digging for this and haven't found it anywhere but it seems really useful.
|
# ? Nov 15, 2012 16:52 |
|
Defghanistan posted:Does anyone know how to find the file associated with the function currently loaded into memory? code:
|
# ? Nov 15, 2012 17:49 |
|
MJP posted:Figured I'd re-inquire... anyone? Sure, something like this. code:
|
# ? Nov 15, 2012 17:59 |
|
kampy posted:
Wow that didn't take long, thank you!
|
# ? Nov 15, 2012 18:31 |
adaz posted:Sure, something like this. So am I looking at this as a possible script: code:
1) When double-clicked, query all site OUs (e.g. one for NYC, one for ATL, one for each other physical location we have) and list the users in the Non-IT Users, Business Users, and Other Users OUs (names changed) 2) Display the results of the query in a dropdown list by Lastname, Firstname 3) Allow user to be selected in the dropdown and click Move in the script 4) When Move is clicked, add the user to a security group - optimally by using dsmove but other workable options should be OK. I was able to use code:
I guess to start: how do I do the listing by last name in a regular old Windows dropdown? Would it be something like this: code:
MJP fucked around with this message at 16:48 on Nov 16, 2012 |
|
# ? Nov 16, 2012 16:39 |
|
MJP you actually don't need the If statement in there, Get-Childitem just won't even return any values that match its exclusion filter. As far as your other problem you get lucky I happen to have made a UI List function before in powershell. In general never try to do GUI stuff in powershell unless you have absolutely no choice. It's doable but as you can see from the code below it's also painful and not straightforward at all. Also Choices should be an enumerable object, like an array of strings. code:
code:
|
# ? Nov 16, 2012 17:02 |
adaz posted:MJP you actually don't need the If statement in there, Get-Childitem just won't even return any values that match its exclusion filter. So how would I use all that to list the contents of the get-aditem cmdlet with all the OUs? If possible can I avoid creating a list to a CSV, or could I include a cmdlet to delete a created list? I'd like to avoid leaving complete lists of all our users on individual machines. For the record, this is being done so individual help desk users can add users to our admin users group so they can install software after approval. Normally we get tickets to do it. This way we just delegate permissions in AD to the help desk people but we don't give them ADUC to do it.
|
|
# ? Nov 16, 2012 17:23 |
|
MJP posted:So how would I use all that to list the contents of the get-aditem cmdlet with all the OUs? If possible can I avoid creating a list to a CSV, or could I include a cmdlet to delete a created list? I'd like to avoid leaving complete lists of all our users on individual machines. I don't use the AD cmdlets so this code might nto work but what you want to do is when you grab your users pipe them through Select-Object and grab the property you want, like CN or DN. then send that list to the Create-Uilist. When the list returns with the user's they have selected iterate through, bind to their AD object and perform whatever operation you want. code:
|
# ? Nov 16, 2012 18:02 |
|
|
# ? May 15, 2024 01:44 |
|
MJP posted:So am I looking at this as a possible script: Nope, that won't really help you. With delprof2, wouldn't you be better off by passing /ed:citrix /ed:admin /ed:track arguments to it directly to exclude certain profiles instead of attempting to use powershell to do so?
|
# ? Nov 17, 2012 12:22 |