|
CLAM DOWN posted:I'm the one running this script so I would only be lying to myself and I don't got no time for that poo poo Sometimes for sanity's sake I like to put stuff like that into a background job and have a spinning progress bar that counts down to when I check the status again. It's shows motion ("no really it is REALLY still running") which helps for those times when you wonder if the script is hung or you accidentally highlighted something, etc
|
# ? Jan 25, 2017 19:34 |
|
|
# ? May 15, 2024 02:55 |
|
Avenging_Mikon posted:Just ordered it. I probably won't get to powershell much, but this is the first excuse I've had to use it at all! It's a good book, but I learned powershell by just googling tasks I wanted to do and built on things from there. Also, I wouldn't directly modify the userAccountControl values manually, change the appropriate settings using the proper command (see anthonypants post about set-aduser and set-adaccountcontrol). I don't have a good reason to say not to do this, just personal preference.
|
# ? Jan 25, 2017 20:45 |
|
skipdogg posted:It's a good book, but I learned powershell by just googling tasks I wanted to do and built on things from there.
|
# ? Jan 25, 2017 20:47 |
|
skipdogg posted:It's a good book, but I learned powershell by just googling tasks I wanted to do and built on things from there. Googling's good and fine, but I learn best by starting top-down, rather than bottom-up, so a textbook is often better for me. skipdogg posted:Also, I wouldn't directly modify the userAccountControl values manually, change the appropriate settings using the proper command (see anthonypants post about set-aduser and set-adaccountcontrol). I don't have a good reason to say not to do this, just personal preference. That actually sounds like a good idea, as that way I get to see more as I'm learning.
|
# ? Jan 25, 2017 21:16 |
|
CLAM DOWN posted:Nope it's variable, and yeah can't run it in a loop I know this isn't possible I'm just venting. Out of interest what's the command you're running which is taking so long?
|
# ? Jan 26, 2017 07:58 |
|
Alright I'm a bit stumped with my current project. I'm trying to automate a lot of the daily repetitive tasks my team and I face. I've actually done so pretty successfully so far but now I'm looking to automate things related to spreadsheet data. Basically I'm starting from square 1 there. I've messed around a little but never stumbled across a way to do either of what I'm looking to do: I have a spreadsheet. The first column is a list of 25-30 $number s which indicate a location. Based on these $number s I already have a test-connection based script which gets ping results for a bunch of formulaic IP addresses. The first step is assuredly the easiest - having one button for: read each $number, dump them all in an array and feed that array, one by one, through my function. It may be significantly harder but I'd also like to automatically put the results in static fields on each row according to column 1's number. Another thing that would help significantly would be done at the same time: take each $number and - in a separate spreadsheet - find the row where column 1 matches $number and pull columns (10-15) from that row. Each field is stored as a different variable to create a partial config that often times needs to be added to a router or switch. e: oh, I'd also like to be able to output the results of my test-connection function back to the original sheet after pulling the list of $number s (to specific fields based on the ordering of the results). I'd also like to be able to output the same thing but for a given $number (only that row). I know the bulk of this will be the same thing but I guess it's the same question as the paragraph above, just inverted. How do I find a line based on a given $number and output data to specific fields? I really only need help with the bolded sections, specifically. I can sterilize the script pretty quickly of anyone wants to look at what I have so far, but I think it wouldn't be especially enlightening or relevant. I realize now this is a lot of explaining and I'm trying to rush through it. So any clarification needed I'll be glad to giveAny help would be appreciated. E2: vvv thanks. I'll check that out. Ugato fucked around with this message at 22:42 on Jan 26, 2017 |
# ? Jan 26, 2017 22:31 |
|
Ugato posted:Alright I'm a bit stumped with my current project. I'm trying to automate a lot of the daily repetitive tasks my team and I face. I've actually done so pretty successfully so far but now I'm looking to automate things related to spreadsheet data. I don't have any specific solutions for you, but my general approach would be to use the Excel module here to import your spreadsheet into powershell objects, do whatever processing I need, then export back to excel.
|
# ? Jan 26, 2017 22:39 |
|
cheese-cube posted:Out of interest what's the command you're running which is taking so long? I can't go into much detail unfortunately but it's a com object function. I could probably rewrite that function to display a progress bar, but that's too much effort for what is in reality a very minor complaint of mine.
|
# ? Jan 26, 2017 23:02 |
|
Alright, here's a rabbit hole I threw myself down today for no good reason: Every now and then somebody wants to know who all is on the receiving end of a group address in out Google Apps environment. This is pretty simple, but we have some groups that contain groups, and this can go down 2-3 levels. (Ex: the devs@company.com group sends to a few individuals, and also to the product@company.com group, which in turn contains the product.interns@company.com group, which is only users) I wrote a script using gShell that went down a level to grab all of the users, but it doesn't really present the information properly (doesn't show what groups people are in, just that they'd get a message sent to the top-level address) and only goes down one level. To resolve the latter issue, I whipped up a recursive function where I feed the highest level group name into: code:
This does the job as far as spitting out a list of the actual groups and then the users in all of them. But it takes a while to do it, so I was trying to make it actually create the group membership lists at it ran so I didn't have to take the output of this and then feed it through another function to get my output that I can send to whoever asked. I figured the "easiest" thing would be to make a hash table, where the key is the group name and the value is an array with the user accounts. But I have no idea how to do that, if it's even possible. I tried to get it going, but the problem is that since $AcctName is getting fed everything, even the users, it just creates a key for each user, with the value of themselves, and then a key for each group that's empty. Is it even possible to do what I'm suggesting here? EDIT: whatis is the only thing I miss from GAM but boy do I miss it sometimes. Inspector_666 fucked around with this message at 23:41 on Jan 26, 2017 |
# ? Jan 26, 2017 23:26 |
|
The gShell wiki helpfully leaves out what the commands' outputs look like, so what does Get-GAGroupMember return, and why does it have a ToArray() method?
|
# ? Jan 27, 2017 00:48 |
|
anthonypants posted:The gShell wiki helpfully leaves out what the commands' outputs look like, so what does Get-GAGroupMember return, and why does it have a ToArray() method? The output is: code:
code:
Practically all of gShell's documentation is procedurally generated, it sucks.
|
# ? Jan 27, 2017 01:09 |
|
Inspector_666 posted:The output is:
|
# ? Jan 27, 2017 01:14 |
|
anthonypants posted:Are Role or Type useful? Jesus loving Christ I can't believe I didn't think of the TYPE field. Groups are Type: GROUP, to the shock of nobody. Well hey I got to play with a recursive function! (I'm going to blame this on my original script just making GBS threads out the membership of the top-level group into a csv and never thinking about why I was actually doing that conversion all the way out.)
|
# ? Jan 27, 2017 01:16 |
|
The Fool posted:I don't have any specific solutions for you, but my general approach would be to use the Excel module here to import your spreadsheet into powershell objects, do whatever processing I need, then export back to excel. I don't know if this will do the writing I need it to do but it definitely does the reading and already appears to order it in a way I can use pretty easily as part of the import process. That definitely gives me something to work with. Thanks!
|
# ? Jan 27, 2017 03:33 |
|
Ugato posted:Alright I'm a bit stumped with my current project. I'm trying to automate a lot of the daily repetitive tasks my team and I face. I've actually done so pretty successfully so far but now I'm looking to automate things related to spreadsheet data. Hey, could you post the script? I'm mostly curious as I haven't done any real spreadsheet specific stuff (like moving between two different ones, like you are wanting to do). The first item seems pretty simply like you said. Define an empty array, pull in your data, iterate through data adding each line's location info to your $location array.
|
# ? Jan 27, 2017 04:28 |
|
I just submitted this issue to allow Set-StrictMode to detect assignment to automatic variables. If you've ever accidentally used one and then got really confused as to why your value was overwritten, but only sometimes, this could be why. Automatic variables that are often used like are $Input, $args, $HOST, etc.
|
# ? Jan 27, 2017 19:43 |
|
I have a list of users pulled from one AD Server using this code:code:
code:
code:
Typing issue? If so how do I fix it? If not, what is going on? Edit: More frustration, the following works fine. code:
edit3: it is a typing issue. The following produced the desired results. code:
The Fool fucked around with this message at 03:01 on Jan 31, 2017 |
# ? Jan 31, 2017 02:32 |
|
Jowj posted:Hey, could you post the script? I'm mostly curious as I haven't done any real spreadsheet specific stuff (like moving between two different ones, like you are wanting to do). The first item seems pretty simply like you said. Define an empty array, pull in your data, iterate through data adding each line's location info to your $location array. Yeah this part I've finally completed. My script is now over 3000 lines with comments and some necessary repetition. Admittedly a big chunk of that is actually just Cisco IOS config stuff that is the main thrust of why I'm doing this thing in the first place (7 different setups all using some variation of the same 20-30 variables, mostly). Importing, automatic FTP'ing and configuration creation are all basically done and QA'd to the point that I'm comfortable with them. So now I'm going to figure out my best way of taking the data I'm scraping from the spreadsheets and actually reformatting it to fit into another sheet to my taste - and something infinitely more readable for my team than the insanity we have now. Once I actually get it done I'll be sure to post back here.
|
# ? Feb 2, 2017 14:02 |
|
Holy gently caress I love powershell. Turns out my supervisor had made a script to grab users from an AD group and output it to a csv file. It took a couple tries to configure the script to what I needed, but the errors were useful and helped me tune it, and now I'm in a terminal server playing around with Powershell ISE to see how it behaves (Only 32-bit Win 7 on the actual desktop, server 2016 on the terminal server), and I'm in god-damned love. I'm debating setting up a vpn to my home computer with Win 10 so I can gently caress around while learning at work without nuking a server accidentally.
|
# ? Feb 2, 2017 20:16 |
|
Avenging_Mikon posted:Holy gently caress I love powershell. Turns out my supervisor had made a script to grab users from an AD group and output it to a csv file. It took a couple tries to configure the script to what I needed, but the errors were useful and helped me tune it, and now I'm in a terminal server playing around with Powershell ISE to see how it behaves (Only 32-bit Win 7 on the actual desktop, server 2016 on the terminal server), and I'm in god-damned love. I'm debating setting up a vpn to my home computer with Win 10 so I can gently caress around while learning at work without nuking a server accidentally. AWS Free Tier dude. Easy way to run a cloud VM for loving around with, without risking anyone's infrastructure.
|
# ? Feb 2, 2017 20:17 |
|
Walked posted:AWS Free Tier dude. Thanks for the heads up, now have a server 2016 instance initializing. This is going to be super-newbie, I know, but how do I RDP to an aws instance? I've only done it to local network computers, or using screen sharing type stuff to my own computer. Edit: never mind... I got it... :facepalm: Bunni-kat fucked around with this message at 22:03 on Feb 2, 2017 |
# ? Feb 2, 2017 21:57 |
|
Avenging_Mikon posted:Thanks for the heads up, now have a server 2016 instance initializing. You're given a public IP and/or DNS to your AWS instance and you just RDP normally to that.
|
# ? Feb 2, 2017 21:59 |
|
Walked posted:AWS Free Tier dude. Is free tier still only available for the first x number of months after account creation, or did they do away with that limitation?
|
# ? Feb 2, 2017 22:05 |
|
CLAM DOWN posted:You're given a public IP and/or DNS to your AWS instance and you just RDP normally to that. Heh, is it literally "put in public IP" and click connect? Like I said, I've only used it for the stuff here at work, and it's just type TS-a107 if you want a terminal server, or FS for file server. But I poked around a bit more and there was a download that I just needed to run, and I figured out the keypair stuff instantly, so Amazon's really made this slick for beginners on this type of thing.
|
# ? Feb 2, 2017 22:10 |
|
Avenging_Mikon posted:Heh, is it literally "put in public IP" and click connect? Like I said, I've only used it for the stuff here at work, and it's just type TS-a107 if you want a terminal server, or FS for file server. Yup, it's that simple. Key pairs are not for RDP but yeah they're very straightforward too!
|
# ? Feb 2, 2017 22:17 |
|
I finished this thing to tell people to reset their passwords, and I think I'm at the point where I'm happy with deploying it. Just gotta test out the scheduled task part and let our users know they're gonna get some not-phishing emails.code:
anthonypants fucked around with this message at 22:19 on Feb 3, 2017 |
# ? Feb 2, 2017 22:32 |
|
I tried to update the help on my new AWS Server 2016 instance, and gooooooot... this:code:
|
# ? Feb 2, 2017 23:08 |
|
Avenging_Mikon posted:Holy gently caress I love powershell. Turns out my supervisor had made a script to grab users from an AD group and output it to a csv file. It took a couple tries to configure the script to what I needed, but the errors were useful and helped me tune it, and now I'm in a terminal server playing around with Powershell ISE to see how it behaves (Only 32-bit Win 7 on the actual desktop, server 2016 on the terminal server), and I'm in god-damned love. I'm debating setting up a vpn to my home computer with Win 10 so I can gently caress around while learning at work without nuking a server accidentally. As you're mentioning different OS versions be mindful of the PowerShell/WMF version that you're working with. Windows 10 and Server 2016 have WMF 5.1 out-of-the-box which is nice however it is incompatible with a lot of products: https://msdn.microsoft.com/en-us/powershell/wmf/5.0/productincompat. I'd recommend targeting your scripts for WMF 4.0 unless your environment is bleeding-edge. You can check the PowerShell version in a session using the $PSVersionTable automatic variable. Avenging_Mikon posted:I tried to update the help on my new AWS Server 2016 instance, and gooooooot... this: Correct, that's just two modules. I'd disregard it. All of the documentation is online as well so you can just Google cmdlet names to get the deets.
|
# ? Feb 4, 2017 09:27 |
|
cheese-cube posted:As you're mentioning different OS versions be mindful of the PowerShell/WMF version that you're working with. Windows 10 and Server 2016 have WMF 5.1 out-of-the-box which is nice however it is incompatible with a lot of products: https://msdn.microsoft.com/en-us/powershell/wmf/5.0/productincompat. I'd recommend targeting your scripts for WMF 4.0 unless your environment is bleeding-edge. You can check the PowerShell version in a session using the $PSVersionTable automatic variable. Thanks. Our terminal servers are officially all 2016 as of Feb 1. I don't know what the file servers are. All new desktops being deployed are Win 10, and ours are due to be replaced in a few months, so I think by the time I'm ready to be doing anything in AD I should be in Win 10. But it's definitely something to keep in mind, because hey, upgrades get delayed. If I'm learning in 5.1, is there a way to check for 4.x compatibility? Should just say in the help in 5.1, right? If I recall, looking at common variables it said in the help some were added in 5.0. Other functions and cmdlets should say that too? And seriously guys, I appreciate the help and understanding. This is all new and exciting to me!
|
# ? Feb 4, 2017 16:28 |
|
Avenging_Mikon posted:If I'm learning in 5.1, is there a way to check for 4.x compatibility? Should just say in the help in 5.1, right? If I recall, looking at common variables it said in the help some were added in 5.0. Other functions and cmdlets should say that too? To be honest I'm not sure what is the easiest way to check what PowerShell version a cmdlet is supported in. It used to be easy when Microsoft hosted the help on TechNet but about 6 months ago they ported it across to MSDN and now everything is all over the joint. I doubt you'll really run into many issues as the number of new cmdlets introduced in 5.1 isn't as many as say 3.0 (That was a huge leap). Feel free to post any questions, I love PowerShell and love spreading wisdom.
|
# ? Feb 7, 2017 11:16 |
|
cheese-cube posted:To be honest I'm not sure what is the easiest way to check what PowerShell version a cmdlet is supported in. It used to be easy when Microsoft hosted the help on TechNet but about 6 months ago they ported it across to MSDN and now everything is all over the joint. I doubt you'll really run into many issues as the number of new cmdlets introduced in 5.1 isn't as many as say 3.0 (That was a huge leap). Some only work on server editions (like Get-WindowsFeature).
|
# ? Feb 7, 2017 23:48 |
|
Okay, so I'm trying to do a lab in Powershell in a Month of Lunches, and early in the chapter, I was able to set the prompt to hkcu:\ and work from there, but trying to go to HKEY_CURRENT_USERS gets me a "drive does not exist with that name" error. I looked in the registry, and it is there. I've tried set-location -Path HKEY_Current_User, with and without a colon and/or backslash, and from multiple directories, ranging from C:\ to HKCU:\ Where am I loving up?
|
# ? Feb 8, 2017 00:57 |
|
Avenging_Mikon posted:Okay, so I'm trying to do a lab in Powershell in a Month of Lunches, and early in the chapter, I was able to set the prompt to hkcu:\ and work from there, but trying to go to HKEY_CURRENT_USERS gets me a "drive does not exist with that name" error. I looked in the registry, and it is there. I've tried set-location -Path HKEY_Current_User, with and without a colon and/or backslash, and from multiple directories, ranging from C:\ to HKCU:\ You can use the command Get-PSDrive to get a list of all current drives, and use the information in the Name field to switch to another drive. So, Set-Location -Path HKCU: should work and does from my machine. Or cd HKCU: if you want to be oldschool
|
# ? Feb 8, 2017 01:04 |
|
Avenging_Mikon posted:Okay, so I'm trying to do a lab in Powershell in a Month of Lunches, and early in the chapter, I was able to set the prompt to hkcu:\ and work from there, but trying to go to HKEY_CURRENT_USERS gets me a "drive does not exist with that name" error. I looked in the registry, and it is there. I've tried set-location -Path HKEY_Current_User, with and without a colon and/or backslash, and from multiple directories, ranging from C:\ to HKCU:\
|
# ? Feb 8, 2017 01:05 |
|
OK, I've spent a lot of time on Google without tripping over any stellar answers, so I thought I'd tap you guys: is there a way to script the setup of the RD Gateway role for Server 2012? All my research leads me to believe this isn't possible, and the only alternative is to instead get Connection Broker/Session Host/Web Access(?) roles going. I'm not even sure if that will end up functionally being the same thing. No one at my company has done this before, so I have no resources to lean on there. We're trying to get their entire environment scripted(we do infrastructure-as-code/"devops") and this is literally the last thing to do - everything else is business as usual. Any advice provided will be greatly appreciated!! Edit: I should clarify that I'm not just looking to do the installation - that's a single line. I need to generate and install a self-signed cert, as well as configure a RAP/CAP and anything else it requires to function. xpander fucked around with this message at 07:32 on Feb 8, 2017 |
# ? Feb 8, 2017 05:31 |
|
anthonypants posted:HKCU is HKEY_CURRENT_USERS Holy poo poo, how have I never made that connection?
|
# ? Feb 8, 2017 15:54 |
Avenging_Mikon posted:
And similar, HKLM = HKEY_LOCAL_MACHINE, HKCR = HKEY_CLASSES_ROOT (which it's important to remember is not a real key, but a combined view of HKLM and HKCU subkeys Software\Classes).
|
|
# ? Feb 8, 2017 16:50 |
|
anthonypants posted:HKCU is HKEY_CURRENT_USERS Just to nitpick, it's HKEY_CURRENT_USER (not users), and it too is not a "real" key; it's mapped to the calling user's HKEY_USERS SID, which is dynamically loaded when the user logs in.
|
# ? Feb 8, 2017 19:45 |
|
God I love learning new poo poo. Just learned how to pipe cmdlets. I had a maniacal grin on my face.
|
# ? Feb 8, 2017 21:20 |
|
|
# ? May 15, 2024 02:55 |
|
Avenging_Mikon posted:God I love learning new poo poo. Just learned how to pipe cmdlets. I had a maniacal grin on my face.
|
# ? Feb 8, 2017 22:04 |