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
Zaepho
Oct 31, 2013

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

Adbot
ADBOT LOVES YOU

skipdogg
Nov 29, 2004
Resident SRT-4 Expert

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.

anthonypants
May 6, 2007

by Nyc_Tattoo
Dinosaur Gum

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.

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.
Yeah, like, you can take a look at the list of values for each flag and you can do the math in your PowerShell to configure the resultant value that you're aiming towards, but good lord do you not want to do that.

Bunni-kat
May 25, 2010

Service Desk B-b-bunny...
How can-ca-caaaaan I
help-p-p-p you?

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.

Pile Of Garbage
May 28, 2007



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?

Ugato
Apr 9, 2009

We're not?
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

The Fool
Oct 16, 2003


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.

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.

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. Any help would be appreciated.

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.

CLAM DOWN
Feb 13, 2007




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.

Inspector_666
Oct 7, 2003

benny with the good hair
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:
function Get-Groups ($AcctName) {
    try {
        $GroupCheck = ((Get-GAGroupMember -GroupName $AcctName).toarray().email)
	$script:ActualGroups += $AcctName
        foreach ($subgroup in $GroupCheck){
            Get-Groups($subgroup)
        }
    }
    catch {
	$script:UserAccts += $AcctName
    }
}
(Unfortunately gShell doesn't evaluate the Get-GAGroupMember command as true/false like you can do with AD stuff, so it has to be try/catch rather than if. The $script: variables are just diagnostic to confirm it was sorting them correctly.)

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

anthonypants
May 6, 2007

by Nyc_Tattoo
Dinosaur Gum
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?

Inspector_666
Oct 7, 2003

benny with the good hair

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:
Email : [email]my.namel@company.com[/email]
ETag  : "An MD5 hash generated per user"
Id    : 21 character long series of digits
Kind  : admin#directory#member
Role  : MEMBER
Type  : USER
And it's a
code:
TypeName: System.Collections.Generic.List`1[[Google.Apis.admin.Directory.directory_v1.Data.Member, gShell,Version=0.9.7.0, Culture=neutral, PublicKeyToken=null]]
Unfortunately, gShell takes pretty much everything as a System.String since it's pretty much just parsing it directly into an API call. .toArray().email gives me an array of just the member e-mail addresses.


Practically all of gShell's documentation is procedurally generated, it sucks.

anthonypants
May 6, 2007

by Nyc_Tattoo
Dinosaur Gum

Inspector_666 posted:

The output is:

code:
Email : [email]my.namel@company.com[/email]
ETag  : "An MD5 hash generated per user"
Id    : 21 character long series of digits
Kind  : admin#directory#member
Role  : MEMBER
Type  : USER
And it's a
code:
TypeName: System.Collections.Generic.List`1[[Google.Apis.admin.Directory.directory_v1.Data.Member, gShell,Version=0.9.7.0, Culture=neutral, PublicKeyToken=null]]
Unfortunately, gShell takes pretty much everything as a System.String since it's pretty much just parsing it directly into an API call. .toArray().email gives me an array of just the member e-mail addresses.


Practically all of gShell's documentation is procedurally generated, it sucks.
Are Role or Type useful?

Inspector_666
Oct 7, 2003

benny with the good hair

anthonypants posted:

Are Role or Type useful?

:suicide:

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.)

Ugato
Apr 9, 2009

We're not?

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!

Jowj
Dec 25, 2010

My favourite player and idol. His battles with his wrists mirror my own battles with the constant disgust I feel towards my zerg bugs.

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.

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.

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.

Briantist
Dec 5, 2003

The Professor does not approve of your post.
Lipstick Apathy
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.

The Fool
Oct 16, 2003


I have a list of users pulled from one AD Server using this code:
code:
$userList = get-aduser -filter * -searchBase $baseOU -server $ADServer -properties $userPropertyList;
$userList = $userList | where {$_.Enabled -eq "True"} | where { $_.PasswordNeverExpires -eq $false } | where { $_.passwordexpired -eq $false };
$userlist = $userlist | Where { $_.PasswordLastSet.AddDays(180) -lt ((Get-Date).AddDays(14)) };
$userList = $userlist | select EmployeeID, Name, EmailAddress, PasswordLastSet, @{Name="PasswordDateExpires";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}};
The next section is supposed to get their email addresses from a different AD server.

code:
 ForEach ($user in $userList)
 {
   $user.EmailAddress = (get-aduser -Identity $user.EmployeeID).EmailAddress;
 }
This section fails with:
code:
get-aduser : Cannot find an object with identity: '16538' under:  'dc=domain,dc=com'
But if I do a "Get-ADUser -Identity 16538" on the command line, it works fine.

Typing issue? If so how do I fix it? If not, what is going on?

Edit: More frustration, the following works fine.
code:
$user = Get-ADuser -Identity 16538 -Properties EmployeeID
Get-AdUser -Identity  $user.EmployeeID
edit2: If you're wondering, EmployeeID and sAMAccountName are always the same in my environment. The same code replacing EmployeeID with sAMAccountName errors in the same way.

edit3: it is a typing issue. The following produced the desired results.
code:
$user.EmailAddress = (get-aduser -Identity ($user.EmployeeID -as [Int32]) -Properties EmailAddress).EmailAddress;
Thanks rubber ducks.

The Fool fucked around with this message at 03:01 on Jan 31, 2017

Ugato
Apr 9, 2009

We're not?

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.

Bunni-kat
May 25, 2010

Service Desk B-b-bunny...
How can-ca-caaaaan I
help-p-p-p you?
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.

Walked
Apr 14, 2003

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.

Bunni-kat
May 25, 2010

Service Desk B-b-bunny...
How can-ca-caaaaan I
help-p-p-p you?

Walked posted:

AWS Free Tier dude.

Easy way to run a cloud VM for loving around with, without risking anyone's infrastructure.

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

CLAM DOWN
Feb 13, 2007




Avenging_Mikon posted:

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.

You're given a public IP and/or DNS to your AWS instance and you just RDP normally to that.

The Fool
Oct 16, 2003


Walked posted:

AWS Free Tier dude.

Easy way to run a cloud VM for loving around with, without risking anyone's infrastructure.

Is free tier still only available for the first x number of months after account creation, or did they do away with that limitation?

Bunni-kat
May 25, 2010

Service Desk B-b-bunny...
How can-ca-caaaaan I
help-p-p-p you?

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.

CLAM DOWN
Feb 13, 2007




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.

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.

Yup, it's that simple. Key pairs are not for RDP but yeah they're very straightforward too!

anthonypants
May 6, 2007

by Nyc_Tattoo
Dinosaur Gum
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:
$pstzone = [System.TimeZoneInfo]::FindSystemTimeZoneById("Pacific Standard Time")
$estzone = [System.TimeZoneInfo]::FindSystemTimeZoneById("Eastern Standard Time")

$pdxusers = Get-ADUser -SearchBase "OU=Portland,DC=domain,DC=local" -Filter * -Properties Mail,PasswordLastSet,LastLogonDate |`
    Where-Object {($_.Enabled -eq $true) -and ($_.PasswordLastSet -ne $null)} |`
    Select-Object Mail,Name,GivenName,PasswordLastSet,LastLogonDate,@{N="PasswordExpiry";E={$_.PasswordLastSet.AddDays(90)}},@{N="Timezone";E={$pstzone}}
$nycusers = Get-ADUser -SearchBase "OU=New York,DC=domain,DC=local" -Filter * -Properties Mail,PasswordLastSet,LastLogonDate |`
    Where-Object {($_.Enabled -eq $true) -and ($_.PasswordLastSet -ne $null)} |`
    Select-Object Mail,Name,GivenName,PasswordLastSet,LastLogonDate,@{N="PasswordExpiry";E={$_.PasswordLastSet.AddDays(90)}},@{N="Timezone";E={$estzone}}
$lexusers = Get-ADUser -SearchBase "OU=Lexington,DC=domain,DC=local" -Filter * -Properties Mail,PasswordLastSet,LastLogonDate |`
    Where-Object {($_.Enabled -eq $true) -and ($_.PasswordLastSet -ne $null)} |`
    Select-Object Mail,Name,GivenName,PasswordLastSet,LastLogonDate,@{N="PasswordExpiry";E={$_.PasswordLastSet.AddDays(90)}},@{N="Timezone";E={$estzone}}

$allusers = @()
$allusers += $pdxusers += $nycusers +=$lexusers

$days = @(15,10,7,5,3,2,1,0)

$smtp = "mailserver.domain.local"
$from = "noreply@domain.com"
$subject = "Your password is about to expire!"

for ($i=0; $i -lt $days.Length; $i++) {
    $days[$i]
    $users = $allusers | Where-Object {$_.PasswordExpiry.ToShortDateString() -eq (Get-Date).AddDays($days[$i]).ToShortDateString()} | Sort-Object PasswordLastSet

    if ($users -ne $null) {
        if ($days[$i] -eq 0) {
            foreach ($u in $users) {
                $subject = "Your password has expired!"
                $to = "$($u.Name) <$($u.Mail)>"
                #$to = @("my account <myemail@domain.com")
                $bcc = "administrator@domain.com"
                $body = "<p>$($u.GivenName),</p>"
                $body +=`
"<p>Your password <b><font color=red>has expired</font></b>. Your password was last changed on $([System.TimeZoneInfo]::ConvertTimeFromUtc($u.PasswordLastSet.ToUniversalTime(), $u.Timezone)) and expired on $([System.TimeZoneInfo]::ConvertTimeFromUtc($u.PasswordExpiry.ToUniversalTime(), $u.Timezone)).</p>"
                $body += "<p>For your convenience, the above times are in your local timezone, $($u.Timezone.StandardName), or $($u.Timezone.DaylightName) when appropriate.</p>"
                $body +=`
"<p>This is an automated message. To reset your password, please email the helpdesk at <a href=`"mailto:helpdesk@domain.com?subject=RE: $($subject)`">helpdesk@domain.com</a>, or give us a call at (666) 420-6969.</p>"
                $body += "<br /><p style=`"font-size:10px`">This message was generated on $($env:computername) at $(Get-Date)</p>"

                Send-MailMessage -SmtpServer $smtp -To $to -Bcc $bcc -From $from -Subject $subject -Body $body -BodyAsHtml -Encoding UTF8
            }
        } else {
            foreach ($u in $users) {
                $to = "$($u.Name) <$($u.Mail)>"
                #$to = @("my account <myemail@domain.com")
                $body = "<p>$($u.GivenName),</p>"
                $body +=`
"<p>Your password will expire in <b><font color=red>$($days[$i]) days</font></b>. Your password was last changed on $([System.TimeZoneInfo]::ConvertTimeFromUtc($u.PasswordLastSet.ToUniversalTime(), $u.Timezone)) and will expire on $([System.TimeZoneInfo]::ConvertTimeFromUtc($u.PasswordExpiry.ToUniversalTime(), $u.Timezone)).</p>"
                $body += "<p>For your convenience, the above times are in your local timezone, $($u.Timezone.StandardName), or $($u.Timezone.DaylightName) when appropriate.</p>"
                $body +=`
"<p>This is an automated message. If you need help changing your password, please email the helpdesk at <a href=`"mailto:helpdesk@domain.com?subject=RE: $($subject)`">helpdesk@domain.com</a>, or give us a call at (666) 420-6969.</p>"
                $body += "<br /><p style=`"font-size:10px`">This message was generated on $($env:computername) at $(Get-Date)</p>"

                Send-MailMessage -SmtpServer $smtp -To $to -From $from -Subject $subject -Body $body -BodyAsHtml -Encoding UTF8
            }
        }
    }
}
e: made some more changes, this time it will actually check if someone's password expires in x days instead of x-y days. also when it emails the user, times are displayed in their local time, and with a link to a timezone calculator for if they're not in that timezone (e.g. travelling). Thought about putting a link to an off-site timezone calculator, but it's better if I don't send around suspicious emails with off-site links in them. I do know we have a couple people who live outside the geographical OUs we have set up, and I think I'll just have to make one-off exceptions for them.

anthonypants fucked around with this message at 22:19 on Feb 3, 2017

Bunni-kat
May 25, 2010

Service Desk B-b-bunny...
How can-ca-caaaaan I
help-p-p-p you?
I tried to update the help on my new AWS Server 2016 instance, and gooooooot... this:
code:
Update-Help : Failed to update Help for the module(s) 'BitsTransfer, Whea' with UI culture(s) 
{en-US} : The value of the HelpInfoUri key in the module manifest must resolve to a container or 
root URL on a website where the help files are stored. The HelpInfoUri 
'https://technet.microsoft.com/en-us/library/dd819413.aspx' does not resolve to a container.
At line:1 char:1
+ Update-Help
+ ~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Update-Help], Exception
    + FullyQualifiedErrorId : InvalidHelpInfoUri,Microsoft.PowerShell.Commands.UpdateHelpCommand
That's just two modules that didn't get updated help, right? Anything I'm going to need to know about those any time soon? Or can I safely disregard this?

Pile Of Garbage
May 28, 2007



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:
code:
Update-Help : Failed to update Help for the module(s) 'BitsTransfer, Whea' with UI culture(s) 
{en-US} : The value of the HelpInfoUri key in the module manifest must resolve to a container or 
root URL on a website where the help files are stored. The HelpInfoUri 
'https://technet.microsoft.com/en-us/library/dd819413.aspx' does not resolve to a container.
At line:1 char:1
+ Update-Help
+ ~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Update-Help], Exception
    + FullyQualifiedErrorId : InvalidHelpInfoUri,Microsoft.PowerShell.Commands.UpdateHelpCommand
That's just two modules that didn't get updated help, right? Anything I'm going to need to know about those any time soon? Or can I safely disregard 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.

Bunni-kat
May 25, 2010

Service Desk B-b-bunny...
How can-ca-caaaaan I
help-p-p-p you?

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.


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.

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!

Pile Of Garbage
May 28, 2007



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.

Briantist
Dec 5, 2003

The Professor does not approve of your post.
Lipstick Apathy

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).

Feel free to post any questions, I love PowerShell and love spreading wisdom.
Part of the complication is also that certain cmdlets require specific OS support, so even if you have the version of PowerShell they were introduced in, you won't be able to run them if you happen to be using it on an earlier OS (by installing a newer version of WMF).

Some only work on server editions (like Get-WindowsFeature).

Bunni-kat
May 25, 2010

Service Desk B-b-bunny...
How can-ca-caaaaan I
help-p-p-p you?
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?

sloshmonger
Mar 21, 2013

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:\

Where am I loving up?

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

anthonypants
May 6, 2007

by Nyc_Tattoo
Dinosaur Gum

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:\

Where am I loving up?
HKCU is HKEY_CURRENT_USERS

xpander
Sep 2, 2004
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

Bunni-kat
May 25, 2010

Service Desk B-b-bunny...
How can-ca-caaaaan I
help-p-p-p you?

anthonypants posted:

HKCU is HKEY_CURRENT_USERS

:aaaaa:

Holy poo poo, how have I never made that connection?

nielsm
Jun 1, 2009



Avenging_Mikon posted:

:aaaaa:

Holy poo poo, how have I never made that connection?

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).

Briantist
Dec 5, 2003

The Professor does not approve of your post.
Lipstick Apathy

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.

Bunni-kat
May 25, 2010

Service Desk B-b-bunny...
How can-ca-caaaaan I
help-p-p-p you?
God I love learning new poo poo. Just learned how to pipe cmdlets. I had a maniacal grin on my face.

Adbot
ADBOT LOVES YOU

Briantist
Dec 5, 2003

The Professor does not approve of your post.
Lipstick Apathy

Avenging_Mikon posted:

God I love learning new poo poo. Just learned how to pipe cmdlets. I had a maniacal grin on my face.
You can do such cool things with piping in PowerShell. The fact that items get sent as whole objects, and that they go through the entire pipeline (usually) is so great. Wait until you start writing your own pipeline-capable functions!

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