|
Drumstick posted:Is there a simple way to change user passwords? I have a csv of the usernames, and the new passwords but Im not sure how to set the new passwords. I have about 11,500 passwords that need changed... The first hit when I typed "Powershell change windows password" into Google was this. Did you try that?
|
# ? Jul 15, 2013 22:13 |
|
|
# ? May 28, 2024 16:18 |
|
Anyone have any experience with the "Powershell Cookbook" books? They are 50% off on oreilly.com right now and I'm tempted...
|
# ? Jul 16, 2013 01:19 |
|
Ithaqua posted:The first hit when I typed "Powershell change windows password" into Google was this. Did you try that? You don't need to gently caress around with ADSI if you have a newer Powershell version: http://ss64.com/ps/ad.html In particular: http://ss64.com/ps/set-adaccountpassword.html You can also use the System.DirectoryServices stuff if you want (which is the way I've done it when I didn't want to have to install the Active Directory module on every PC running my script or when I wanted to "sketch out" something that was going to be C# eventually). RICHUNCLEPENNYBAGS fucked around with this message at 03:07 on Jul 16, 2013 |
# ? Jul 16, 2013 03:00 |
|
Well, I went to post a big thing about how I couldnt get it to work and it turns out I just cant spell. Thanks for the help! Its working great, I want to run it through another time or two before hitting it all.
|
# ? Jul 16, 2013 20:24 |
|
I've got a script I need assistance with. It's ping but with a timestamp and table formatting:code:
Ex results: Factor Mystic fucked around with this message at 15:40 on Jul 24, 2013 |
# ? Jul 24, 2013 15:36 |
|
One workaround I just tested is to stick | Out-String -Stream | Select-String "." after the Format-Table. This will only print the lines that aren't blank.
|
# ? Jul 24, 2013 17:09 |
|
Jethro posted:One workaround I just tested is to stick | Out-String -Stream | Select-String "." after the Format-Table. This will only print the lines that aren't blank. Dynamite. Thank you.
|
# ? Jul 24, 2013 17:57 |
|
Are there any idiot's guides to powershell floating around? I'm basically bereft of scripting experience, and it's something I'm trying to pick up, but while there's a lot of resources for learning python (like codecademy, etc), I haven't found anything similarly entry-level for powershell.
|
# ? Jul 25, 2013 15:19 |
|
Falcon2001 posted:Are there any idiot's guides to powershell floating around? I'm basically bereft of scripting experience, and it's something I'm trying to pick up, but while there's a lot of resources for learning python (like codecademy, etc), I haven't found anything similarly entry-level for powershell. Learn Powershell 3 in a Month of Lunches. Also, every command is well documented. Just type Get-Help and then the command. You can add -full and you'll get examples too.
|
# ? Jul 25, 2013 16:09 |
|
Dr. Arbitrary posted:Learn Powershell 3 in a Month of Lunches. Thanks! The problem is that I don't have a good handle on scripting at all beyond very simple things, so the documentation on commands will be really good...once I know what I even want to be doing. It's somewhat embarassing that I don't know this stuff, but nothing like trying to get into it, I suppose.
|
# ? Jul 25, 2013 17:33 |
|
Factor Mystic posted:
I don't think it answers your need for a timestamp, but I just want to point out that the Test-Connection commandlet exists and gives tabular output by default: http://technet.microsoft.com/en-us/library/hh849808.aspx
|
# ? Jul 26, 2013 05:29 |
|
Falcon2001 posted:Thanks! The problem is that I don't have a good handle on scripting at all beyond very simple things, so the documentation on commands will be really good...once I know what I even want to be doing. It's somewhat embarassing that I don't know this stuff, but nothing like trying to get into it, I suppose. That whole book barely even touches on scripting, it's all about using it as a shell just like a badass version of DOS. I have a lot of luck just googling things like "powershell map network drive". Just get help on each command and you'll be set. The coolest thing you need to know is about the pipe. | It takes the output of one command and pipes it to the input of the next. Most of the time it just works right. Try using Dos commands you already know like ipconfig or arp and then piping them to a utility command like Out-File or Out-Gridview. This instantly gives you some new power. Eventually you'll want to get away from Dos because those commands aren't compatible in a lot of ways. That's when you'll start researching WMI. I'm literally only a month or two more experienced than you on powershell, if you have any IT background you'll be leaving me in the dust in no time.
|
# ? Jul 26, 2013 07:43 |
|
So yeah, that book's pretty awesome. The biggest problem I have right now is that I just don't have much to do with it since I don't actively administrate any servers. :\ Weird infrastructure. But the book itself is rad.
|
# ? Jul 28, 2013 05:16 |
|
I'm actually having a lot of fun learning how to do stuff without having to use menus. If I want to turn off offline files I don't open the sync center. I do it through WMI. It makes me feel POWERFUL.
|
# ? Jul 28, 2013 05:24 |
|
I had the impression (mostly from reading a significant portion of it) that Windows PowerShell in Action was the one to beat.
|
# ? Jul 30, 2013 04:20 |
|
RICHUNCLEPENNYBAGS posted:I don't think it answers your need for a timestamp, but I just want to point out that the Test-Connection commandlet exists and gives tabular output by default: http://technet.microsoft.com/en-us/library/hh849808.aspx Thanks for the tip, but as you said there's no timestamp and I also couldn't figure out how to get it to ping forever (though, to be fair neither did the script I posted).
|
# ? Aug 8, 2013 16:06 |
|
Factor Mystic posted:Thanks for the tip, but as you said there's no timestamp and I also couldn't figure out how to get it to ping forever (though, to be fair neither did the script I posted). PowerShell code:
pre:TimeStamp Destination IPV4Address ResponseTime Status --------- ----------- ----------- ------------ ------ 8/8/2013 20:04:01 google.com 74.125.142.113 21 OK 8/8/2013 20:04:02 google.com 74.125.142.113 19 OK 8/8/2013 20:04:03 google.com 74.125.142.113 21 OK 8/8/2013 20:04:04 google.com 74.125.142.113 20 OK 8/8/2013 20:04:05 google.com 74.125.142.113 21 OK e: tables Mario fucked around with this message at 03:08 on Aug 9, 2013 |
# ? Aug 9, 2013 03:06 |
|
OK, I feel stupid. How do you properly move contents of one directory to another? It seems like an extremely simple task but if they both contain same-named directories it turns ugly. Let's have directory structure like:code:
code:
Move-Item : Cannot create a file when that file already exists. b\ still contains aa\, it's not copied/merged into a\. Tried code:
Edit: "copy-item -path b\* -destination a -recurse -force" seems to work fine, just need to delete the source after. Meh. omeg fucked around with this message at 01:04 on Aug 21, 2013 |
# ? Aug 21, 2013 00:37 |
|
Is there a way to use invoke-command as a sort of fire and forget mechanism instead of waiting for output. I want to kick off a script on a number of computers that I know will hang then error out on a handful of them, but don't want to deal with the waiting and error handling. The plan is to use something likecode:
code:
|
# ? Aug 23, 2013 15:08 |
|
-AsJob is the parameter you're looking for. Then you can save the result as a Job object you can check on later with Receive-Job.
|
# ? Aug 23, 2013 15:27 |
|
Just to confirm. The Learn Powershell in 30 Lunches book is good for absolute beginners to Powershell, right. What about someone who is new to scripting in general? I'd eventually like to automate some tasks but reading scripting tutorials for Powershell on the net makes me feel stupid for just not really getting it.
|
# ? Aug 27, 2013 22:14 |
|
along the way posted:Just to confirm. The Learn Powershell in 30 Lunches book is good for absolute beginners to Powershell, right. Do you have any programming experience at all? If you don't, it might be worth doing a basic python/ruby tutorial. I haven't done it, but this doesn't look terrible: http://www.learnpython.org/
|
# ? Aug 27, 2013 22:20 |
|
along the way posted:Just to confirm. The Learn Powershell in 30 Lunches book is good for absolute beginners to Powershell, right. "Learn PowerShell Toolmaking in a Month of Lunches" is good for people who already know Powershell but want to get into scripting. The basic book "Learn Windows PowerShell 3 in a Month of Lunches" is appropriate for people who have no experience with Powershell or scripting.
|
# ? Aug 27, 2013 22:23 |
|
EAT THE EGGS RICOLA posted:Do you have any programming experience at all? If you don't, it might be worth doing a basic python/ruby tutorial. None at all. I've been a desktop/server/networking monkey for 8 years but I'm beginning to feel limited without programming/scripting experience. Thanks, I'll take a look. Edit: Cool, I'll tackle the first book then the second and see how it goes.
|
# ? Aug 27, 2013 22:23 |
|
along the way posted:None at all. I've been a desktop/server/networking monkey for 8 years but I'm beginning to feel limited without programming/scripting experience. You'll probably be way ahead of the game. I had (and continue to have) a lot of difficulty because I don't have much understanding of things like RPC that are important when automating things that affect remote servers.
|
# ? Aug 27, 2013 23:06 |
|
Having troubles with a script I threw together to get/set a list of files that are not owned by BUILTIN\Administrators. It seems to work fine but takes a loooong time to run (~29 hours) on a file server hosting a lot of files. The script is running from the server host the files, and I know I have at least one issue: the Get-ChildItem seems to run relatively quickly, in about an hour or two, and then the foreach loops seems to take up the rest of the time. This presents a problem because when running this on the large shares as the difference in the results from Get-ChildItem and the actual list of files grows and when the file gets run through the foreach loop, the file may no longer exist, which ends up giving me a lot of false positives. For example, I took the results of this with the noncompliant option (just reports users that are not owned by BUILTIN\Administrators) which was an 89 MB csv file and filtered out everything that did not have a blank owner which left me with 720 results and ran that through Test-Path which left me with only 15 files that still existed. I know I could probably fix this at least by doing a test-path within the foreach loop before grabbing the properties, but I'd really like to find out where exactly the slowness is coming from, and how I can possibly resolve. Anyone have any ideas? I've stripped it down to what I think are the only relevant portions of the script, I can attach the whole thing if needed: code:
|
# ? Sep 18, 2013 20:24 |
My current scripting hopeful task: I need to identify if files are still in use so we can delete them. I have the following set up which shows me the last access time:code:
It looks like in Powershell property terms, LastAccessTime is basically last time a file was modified. Is there anything for last time a file was read, or even opened/touched?
|
|
# ? Sep 19, 2013 20:52 |
|
Last access time tracking might be disabled on NTFS volumes. I wouldn't rely on it.
|
# ? Sep 20, 2013 00:30 |
|
I'm trying to pass an object by reference to a test function. The idea is that I will call this function with an ACL and and ACE to add/remove along with other stuff. The problem is when I try to run AddAccessRule, with the error shown below. Can't find an exact example of what I'm trying to do yet, so I thought I'd check here. Also, I tend to find the answer right after posting a question, so I'm trying that theory out. code:
|
# ? Oct 11, 2013 22:03 |
|
Recluse posted:I believe it's the foreach loop in the FileList function because when I hit a folder or file that I don't have rights to, I get an error message when trying to add the owner property and I'd see those pop-up every few hours until it finished whereas the Get-ChildItem should only run once in the beginning. You might have figured this out by now but it's your use of Add-Member. There's a lot of old Powershell v1 advice floating about on the web that has been superseded by much better tools in v2 and v3, this is one. In this case there's some advice here on just how slow Add-Member is and how to make custom objects quicker. Drighton posted:I'm trying to pass an object by reference to a test function. The idea is that I will call this function with an ACL and and ACE to add/remove along with other stuff. The problem is when I try to run AddAccessRule, with the error shown below. Can't find an exact example of what I'm trying to do yet, so I thought I'd check here. Also, I tend to find the answer right after posting a question, so I'm trying that theory out. I might not be understanding right (I'm not great with coding jargon) but I think Get-Acl is already one step ahead of you. The object you get as output is just a copy of the ACL, if you make any changes to it then you still need to apply them to a target with Set-Acl (or equivalent) afterwards. For example, to take ownership of a folder: code:
E: Just realised that part doesn't actually use Get-Acl, whoops! I'll see if I can't find the right script I was thinking of. Scikar fucked around with this message at 13:35 on Oct 15, 2013 |
# ? Oct 15, 2013 13:27 |
|
I need to use the shutdown command to restart a computer group in an AD domain. I was told this can only be achieved with a Powershell ISE script,a language in which I'm completely ignorant. The following code was suggested.code:
Thank you very very much!
|
# ? Oct 18, 2013 09:15 |
|
H.H posted:I need to use the shutdown command to restart a computer group in an AD domain. I was told this can only be achieved with a Powershell ISE script,a language in which I'm completely ignorant. The following code was suggested. It's reading a list of computers from an input file, then iterating over every line in the file and shutting it down. You run the script with a command line argument giving the path to the file.
|
# ? Oct 18, 2013 15:47 |
|
Ithaqua posted:It's reading a list of computers from an input file, then iterating over every line in the file and shutting it down. You run the script with a command line argument giving the path to the file. So the command should be "shutdown_script comp_group.txt"?
|
# ? Oct 18, 2013 17:29 |
|
H.H posted:I need to use the shutdown command to restart a computer group in an AD domain. I was told this can only be achieved with a Powershell ISE script,a language in which I'm completely ignorant. The following code was suggested. There's nothing wrong with the code you were given, but here's some code that I've written that's a little more beginner friendly. code:
The plus side is that every command in it is well documented and easy to understand, compared to goofing around with WMI. Get-Content grabs all the servers in c:\servers.txt the pipe: " | " sends that list to the next command "ForEach-Object" For each of those servers it tries to execute the command "Restart-Computer" with the argument -Computername $_ ($_ is a special character that represents the current object being manipulated by ForEach-Object) There's no error detection so you should probably go with your other script for actual work.
|
# ? Oct 18, 2013 18:17 |
|
Has anyone tried out the idempotent Desired State Configuration stuff in PS 4.0 yet? If the given types do enough things, it seems like a really plausible alternative to Puppet/Chef/SCCM for Windows systems management.
|
# ? Oct 19, 2013 00:42 |
|
Dr. Arbitrary posted:There's nothing wrong with the code you were given, but here's some code that I've written that's a little more beginner friendly. I need to run the script as a task at midnight, so as not to restart everyone's computer in the middle of the day, so I'll try the other script. Thanks anyway!
|
# ? Oct 19, 2013 01:54 |
|
H.H posted:I need to run the script as a task at midnight, so as not to restart everyone's computer in the middle of the day, so I'll try the other script. Thanks anyway! That's probably a much better idea, I just wanted to show you a simpler idea so you can get an idea of how it all works together. I'm thinking that you could get the scrip working even better by running the commands as jobs, that way it'll send everything out simultaneously instead of one at a time.
|
# ? Oct 19, 2013 02:06 |
|
You should be using some variant of Get-ADComputer -SearchBase to find the computers rather than relying on an input file, otherwise you'll have to update the file with machine names every time one gets added.
|
# ? Oct 19, 2013 02:49 |
|
I've been trying to get those AD commands to work for quite a while. I'm pretty sure that the problem is that Server 2008 SP2 isn't the same thing as Server 2008 R2. I've got to get some upgrades in this place.
|
# ? Oct 19, 2013 03:17 |
|
|
# ? May 28, 2024 16:18 |
|
Dr. Arbitrary posted:I've been trying to get those AD commands to work for quite a while. I'm pretty sure that the problem is that Server 2008 SP2 isn't the same thing as Server 2008 R2. If you're on Win 7, download this then enable the Active Directory Module for Powershell Feature. It's under the Remote Server Admin Tool feature somewhere. Then either open powershell through the admin tools menu, using the shortcut that includes active directory, or open powershell and do an Import-Module Activedirectory Edit: Oh, you can also avoid this altogether by just remoting out: Enter-PSSession -ComputerName hostname –credential domain\AD_admin EAT THE EGGS RICOLA fucked around with this message at 04:11 on Oct 19, 2013 |
# ? Oct 19, 2013 04:07 |