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
Bunni-kat
May 25, 2010

Service Desk B-b-bunny...
How can-ca-caaaaan I
help-p-p-p you?
Okay, I'm still at regular OS level of learning stuff with powershell, but I just got tossed a task because I'm the only one who knows any PS in the office. I need the accounts of people in our AD's VPN group, but also a bunch of information on those accounts.

I've got
code:
GET-ADGROUPMEMBER -IDENTITY “NAME OF GROUP” | SELECT NAME | EXPORT-CSV –PATH C:\OUTPUT\GROUPMEMBERS.CSV -NOTYPEINFORMATION
to get the names. But looking at the help, I can't figure out the parameters to get stuff like UserID, creation date, last login, etc. I know it's going in the "select" section where Name is, but I can't find a list of the proper names of the attributes I'm looking for. The online help page didn't have anything I could see.

Adbot
ADBOT LOVES YOU

thebigcow
Jan 3, 2001

Bully!
I also have zero experience with the AD cmdlets. Is the information you need available from Get-ADUser? If so you can probably pipe the Get-ADGroupMember results into either Get-ADUser directly, or into a ForEach-Object with a scriptblock that grabs what you need.

Bunni-kat
May 25, 2010

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

thebigcow posted:

I also have zero experience with the AD cmdlets. Is the information you need available from Get-ADUser? If so you can probably pipe the Get-ADGroupMember results into either Get-ADUser directly, or into a ForEach-Object with a scriptblock that grabs what you need.

Thanks! That gets me a hell of a lot closer than I was, and now I just need to mess with the properties part. For some reason in my head I thought all the info should still be in the groupmember results instead of in user.

nielsm
Jun 1, 2009



Yes, Get-ADGroupMember returns you sparsely populated generic AD objects, since groups can contain just about any kind of object as member. If you know only users are members of the group, you can safely pass the result of that straight into Get-ADUser to get all the details, optionally passing -Properties to Get-ADUser to get more than the default property set. For example:
code:
Get-ADGroupMember -Recursive -Identity "VPN Users" | Get-ADUser -Properties Department,Title | Select Name, Department, Title, Enabled | Export-Csv "vpnusers.csv" -NoTypeInformation
Also please don't shout at PowerShell. It responds just as well to politely typed CamelCase. ;)

The Fool
Oct 16, 2003


thebigcow posted:

I also have zero experience with the AD cmdlets. Is the information you need available from Get-ADUser? If so you can probably pipe the Get-ADGroupMember results into either Get-ADUser directly, or into a ForEach-Object with a scriptblock that grabs what you need.

Piping works. Ex:

code:
get-adgroupmember -Identity "GroupName" | get-aduser -property lastlogontimestamp | select-object samaccountname, lastlogontimestamp
efb, with a better example

anthonypants
May 6, 2007

by Nyc_Tattoo
Dinosaur Gum

Avenging_Mikon posted:

Okay, I'm still at regular OS level of learning stuff with powershell, but I just got tossed a task because I'm the only one who knows any PS in the office. I need the accounts of people in our AD's VPN group, but also a bunch of information on those accounts.

I've got
code:
GET-ADGROUPMEMBER -IDENTITY “NAME OF GROUP” | SELECT NAME | EXPORT-CSV –PATH C:\OUTPUT\GROUPMEMBERS.CSV -NOTYPEINFORMATION
to get the names. But looking at the help, I can't figure out the parameters to get stuff like UserID, creation date, last login, etc. I know it's going in the "select" section where Name is, but I can't find a list of the proper names of the attributes I'm looking for. The online help page didn't have anything I could see.
If you're using Get-ADGroupMember, you only get a few properties. So instead, what you want to do is pipe the results of Get-ADGroupMember into Get-ADUser.
code:
Get-ADGroupMember -Identity "NAME OF GROUP | Get-ADUser | Select-Object Name | Export-Csv
However, some of those things you want won't be in the default Get-ADUser output, so you can specify all of them
code:
Get-ADGroupMember -Identity "NAME OF GROUP | Get-ADUser -Properties * | Select-Object Name,LastLogonDate | Export-Csv
or you can select just the extra ones you want, to speed up the script a little bit
code:
Get-ADGroupMember -Identity "NAME OF GROUP | Get-ADUser -Properties LastLogonDate | Select-Object Name,LastLogonDate | Export-Csv
If you have a group with groups in it, and you want to find all the recursive users, you can tell Get-ADGroupMember to find those people, too
code:
Get-ADGroupMember -Recursive -Identity "NAME OF GROUP | Get-ADUser -Properties LastLogonDate | Select-Object Name,LastLogonDate | Export-Csv
If you don't, it'll error out when it can't run Get-ADUser against a group, but that won't be a huge deal.

Bunni-kat
May 25, 2010

Service Desk B-b-bunny...
How can-ca-caaaaan I
help-p-p-p you?
I piped to get-aduser and did the -properties * because it's for an audit and gently caress auditors (mostly not really). Hilariously it generates a 2MB xls file for the first group. If they come back annoyed, then I'll actually put effort in to get just the properties they wanted. What I really should have done is also find a way to make the command run against all 9 groups at once instead of modifying the script for each vpn group. I guess that will be my next lesson.

The Fool
Oct 16, 2003


Avenging_Mikon posted:

I piped to get-aduser and did the -properties * because it's for an audit and gently caress auditors (mostly not really). Hilariously it generates a 2MB xls file for the first group. If they come back annoyed, then I'll actually put effort in to get just the properties they wanted. What I really should have done is also find a way to make the command run against all 9 groups at once instead of modifying the script for each vpn group. I guess that will be my next lesson.

Create a list of the groups, then ForEach through it.

Collateral Damage
Jun 13, 2009

Avenging_Mikon posted:

I piped to get-aduser and did the -properties * because it's for an audit and gently caress auditors (mostly not really). Hilariously it generates a 2MB xls file for the first group. If they come back annoyed, then I'll actually put effort in to get just the properties they wanted. What I really should have done is also find a way to make the command run against all 9 groups at once instead of modifying the script for each vpn group. I guess that will be my next lesson.

code:
$groups = @("Group 1","Group 2","Group 3")
ForEach ($group in $groups) {
    Get-ADGroupMember -Recursive -Identity $group | Get-ADUser -Properties LastLogonDate | select Name,SamAccountName,LastLogonDate | export-csv $($group).csv
}
Alternatively if you just want a big list of users who are members of at least one of the groups:
code:
$groups = @("Group 1","Group 2","Group 3")
$result = @()
ForEach ($group in $groups) {
    $result += (Get-ADGroupMember -Recursive -Identity $group | Get-ADUser -Properties LastLogonDate)
}
$result | Select Name,SamAccountName,LastLogonDate -Unique | export-csv -File users.csv

Collateral Damage fucked around with this message at 10:09 on Mar 31, 2017

Bunni-kat
May 25, 2010

Service Desk B-b-bunny...
How can-ca-caaaaan I
help-p-p-p you?
Geez, that looks baller. Is the recursive actually necessary if each group doesn't have groups within it, though? Just 9 groups all separate? I thought that was only if it was nested groups.

anthonypants
May 6, 2007

by Nyc_Tattoo
Dinosaur Gum

Avenging_Mikon posted:

Geez, that looks baller. Is the recursive actually necessary if each group doesn't have groups within it, though? Just 9 groups all separate? I thought that was only if it was nested groups.
It's just if there are nested groups, but nobody knows what your groups look like. It's the same reason they did a Select-Object -Unique to get rid of users who are in multiple selected groups, even though we don't know if that's the case.

Collateral Damage
Jun 13, 2009

No, it's not strictly needed unless you have nested groups, but unless you explicitly don't want to traverse nested groups it's good practice to use it anyway.

Bunni-kat
May 25, 2010

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

anthonypants posted:

It's the same reason they did a Select-Object -Unique to get rid of users who are in multiple selected groups,

whoops, didn't even notice that part. Well, I'm taking what I've learned and am now making a script to disable AD accounts and update their description with the date they were disabled.

I've got everything set except I've forgotten how to pipe a file in to anything. And apparently get-file isn't recognized in the Active Directory Module. I'd really like to be able to point this at a file of user names and just have it go nuts, and then only need to change the file each time.

Dr. Arbitrary
Mar 15, 2006

Bleak Gremlin
Get-Content will get the contents of a file.
Unless you want to actually manipulate a file, like rename it or something, in which case you'd use Get-Item.

nielsm
Jun 1, 2009



Avenging_Mikon posted:

whoops, didn't even notice that part. Well, I'm taking what I've learned and am now making a script to disable AD accounts and update their description with the date they were disabled.

I've got everything set except I've forgotten how to pipe a file in to anything. And apparently get-file isn't recognized in the Active Directory Module. I'd really like to be able to point this at a file of user names and just have it go nuts, and then only need to change the file each time.

Plain text: Get-Content -Path "c:\some\file.txt" -Encoding UTF8

CSV: Import-Csv -Path "C:\some\file.csv" -Header @("UserName","FirstName","LastName","Email")

Mo_Steel
Mar 7, 2008

Let's Clock Into The Sunset Together

Fun Shoe

Avenging_Mikon posted:

whoops, didn't even notice that part. Well, I'm taking what I've learned and am now making a script to disable AD accounts and update their description with the date they were disabled.

I've got everything set except I've forgotten how to pipe a file in to anything. And apparently get-file isn't recognized in the Active Directory Module. I'd really like to be able to point this at a file of user names and just have it go nuts, and then only need to change the file each time.

As mentioned above, Get-Content will do this; structure the text file as one username per line:

code:
BRoss
BGates
SSilverman
Something like this would probably work:

code:
$userList = Get-Content "c:\users.txt"
$currentDate = Get-Date -Format yyyy-MM-dd

foreach ($user in $userList) {
	"Disabling user account $userList on $currentDate"
	Set-ADUser $user -Description "Disabled on $currentDate"
	Disable-ADAccount $user  
}
Save as a ps1 script file and then you can do stuff like pipe the output to a log file when you run it manually or as a scheduled task:

code:
.\remove-users.ps1 | out-file log.txt
Obvious note: test this kind of scripting carefully on dummy accounts before you go deploying it in a production environment.

Collateral Damage
Jun 13, 2009

Use -WhatIf on the set and disable commands for a dry run

Briantist
Dec 5, 2003

The Professor does not approve of your post.
Lipstick Apathy

Collateral Damage posted:

Use -WhatIf on the set and disable commands for a dry run
Also a good reason to write your own functions and scripts to support -WhatIf.

The status gets passed along automatically, so in some cases you don't even have to write code to have your own stuff work like this.

Example:

code:
function Set-MyCompanyStuff {
[CmdletBinding(SupportsShouldProcess = $true)]  # SupportsShouldProcess enables the -WhatIf switch, signals that your function properly supports this
param()

    # Do stuff
    Set-ADAccount #params
    Disable-ADAccount  #params
}
By calling Set-MyCompanyStuff -WhatIf you implicitly call the underlying cmdlets/functions with it as well. Essentially it sets $WhatIfPreference inside your function's scope.

If you can't directly rely on it being implicit (certain workflows wouldn't work well that way) then use $PSCmdlet.ShouldProcess() in an if block.

For example if your code uses loops or expensive/long-running Get- calls (which pretty much never support -WhatIf since they don't change anything), you might want to avoid those when changes won't be made anyway. Also for patterns where you create something, then act on it. A call can still fail with -WhatIf if the object in question doesn't exist (because a previous call to create it never actually created it).

code:
function New-CompanyUser {
[CmdletBinding(SupportsShouldProcess = $true)] 
param($nuName)

    $newUser = New-ADUser  -Name $nuName # implicit -WhatIf

    if ($PSCmdlet.ShouldProcess($nuName <# target #> , 'Setting additional attributes' <# action #>)) {
        $newUser | Set-ADUser #params
        $newUser | Set-ADPrincipalGroupMembership #params
    }
}
Another cool thing about using $PSCmdlet.ShouldProcess is that it automatically gives you verbose output if you call your function with -Verbose instead of -WhatIf.

The Electronaut
May 10, 2009
Going to SANS Orlando Sunday through Friday for Securing Powershell. Didn't expect the approval, it was a throw away request, so this should be fun.

Briantist
Dec 5, 2003

The Professor does not approve of your post.
Lipstick Apathy
NYC folks, come check out Techstravaganza on Fri, Apr 28.

I'll be there, lots of PowerShell MVPs and hopefully some good talks (not just PowerShell stuff).

Only costs :10bux: so probably not getting reimbursed at work but hopefully they'll give you the day to go.

Eschatos
Apr 10, 2013


pictured: Big Cum's Most Monstrous Ambassador
I wrote a script! Inspired by a script someone else posted that inventories PCs by subnet, I wrote my own take on it that uses AD information instead. My first real script more than a few dozen lines, and definitely made for a great learning experience.

Link

It works by taking a list of all computers from Active Directory, then filtering out all non-desktop OSes. It then iterates through the list, running a bunch of WMI queries on every computer and kludging the results together into one big array, which is then saved to a .csv on disk. The bit that I'm particularly happy with is now it can save a master .csv and compare new results with it, overwriting old information or failed queries with more up to date results. In the future I plan to improve it by having it query more potentially useful information from PCs, figure out how to autorun it daily from one of our servers, and run the queries as jobs so that it doesn't take two hours to scan everything.

PBS
Sep 21, 2015

Eschatos posted:

I wrote a script! Inspired by a script someone else posted that inventories PCs by subnet, I wrote my own take on it that uses AD information instead. My first real script more than a few dozen lines, and definitely made for a great learning experience.

Link

It works by taking a list of all computers from Active Directory, then filtering out all non-desktop OSes. It then iterates through the list, running a bunch of WMI queries on every computer and kludging the results together into one big array, which is then saved to a .csv on disk. The bit that I'm particularly happy with is now it can save a master .csv and compare new results with it, overwriting old information or failed queries with more up to date results. In the future I plan to improve it by having it query more potentially useful information from PCs, figure out how to autorun it daily from one of our servers, and run the queries as jobs so that it doesn't take two hours to scan everything.

There's a ton of overhead with powershell when using jobs in my experience, if you want it to run more quickly you probably really don't want to do it as each machine is a job.

You can do your own testing, but the best way is probably to split up all the machines between a few jobs and run it that way.

Runspaces may be a little better but I haven't played around with them too much, it gets complex pretty fast.

Pile Of Garbage
May 28, 2007



Eschatos posted:

I wrote a script! Inspired by a script someone else posted that inventories PCs by subnet, I wrote my own take on it that uses AD information instead. My first real script more than a few dozen lines, and definitely made for a great learning experience.

Link

It works by taking a list of all computers from Active Directory, then filtering out all non-desktop OSes. It then iterates through the list, running a bunch of WMI queries on every computer and kludging the results together into one big array, which is then saved to a .csv on disk. The bit that I'm particularly happy with is now it can save a master .csv and compare new results with it, overwriting old information or failed queries with more up to date results. In the future I plan to improve it by having it query more potentially useful information from PCs, figure out how to autorun it daily from one of our servers, and run the queries as jobs so that it doesn't take two hours to scan everything.

To expand on what PBS has said, each PS job is spawned in a separate powershell.exe process which consumes 30-50MB of memory. You can very quickly consume all available memory on a system which will cause the calling PS instance to throw an exception.

If you have a task which involves executing commands against a large number of remote systems and you want to run it in parallel then it is better to use remoting to run the commands on the remote systems themselves.

If you do want to run the jobs locally then you'll have to implement a throttling routine which backs-off on spawning jobs until execution concurrency is below a certain threshold.

PBS
Sep 21, 2015

cheese-cube posted:

To expand on what PBS has said, each PS job is spawned in a separate powershell.exe process which consumes 30-50MB of memory. You can very quickly consume all available memory on a system which will cause the calling PS instance to throw an exception.

If you have a task which involves executing commands against a large number of remote systems and you want to run it in parallel then it is better to use remoting to run the commands on the remote systems themselves.

If you do want to run the jobs locally then you'll have to implement a throttling routine which backs-off on spawning jobs until execution concurrency is below a certain threshold.

I was actually ignoring resource usage since I assume someone would implement throttling anyway. (No one would try to query 200 machines at once right?)

The real issue is how long it takes to start up, run, and close the job. If you do a single job per machine you're likely looking at at least 2x the amount of time to run as if you didn't use jobs.

Again I could be wrong, so try it out on your own, just don't be surprised if it's slower than anticipated.

Pile Of Garbage
May 28, 2007



Your assumptions are naive and I think you should rethink things and aim towards scalability if you want your script to be anything other than a pet project.

PBS
Sep 21, 2015

cheese-cube posted:

Your assumptions are naive and I think you should rethink things and aim towards scalability if you want your script to be anything other than a pet project.

Not my script?

Unsure what comment you're gooning about specifically.

I'm not saying don't use jobs or parallelization, but jobs generally should not be used to spin up individual quick tasks. Most WMI queries will take less than 1s to run and return a result. I imagine you'd have to run quite a few jobs at once to outweigh the startup costs for a powershell job. He would need to do his own benchmarking to figure out if he can realistically run enough at once to outweigh those costs.

Executing the command on the remote machine (assuming WinRM is setup) would offload resources at the likely cost of a slight increase in total time to receive a result.

PBS fucked around with this message at 15:01 on Apr 8, 2017

Briantist
Dec 5, 2003

The Professor does not approve of your post.
Lipstick Apathy
Please vote on this uservoice issue to fix glaring inconsistencies and bugs in the DnsServer module's handling of -Verbose, -WhatIf, and -ErrorAction.

Roargasm
Oct 21, 2010

Hate to sound sleazy
But tease me
I don't want it if it's that easy

Eschatos posted:

I wrote a script! Inspired by a script someone else posted that inventories PCs by subnet, I wrote my own take on it that uses AD information instead. My first real script more than a few dozen lines, and definitely made for a great learning experience.

Link

It works by taking a list of all computers from Active Directory, then filtering out all non-desktop OSes. It then iterates through the list, running a bunch of WMI queries on every computer and kludging the results together into one big array, which is then saved to a .csv on disk. The bit that I'm particularly happy with is now it can save a master .csv and compare new results with it, overwriting old information or failed queries with more up to date results. In the future I plan to improve it by having it query more potentially useful information from PCs, figure out how to autorun it daily from one of our servers, and run the queries as jobs so that it doesn't take two hours to scan everything.

Here's my take at something similar if you want to steal anything:

https://pastebin.com/YbPbacf8

Briantist
Dec 5, 2003

The Professor does not approve of your post.
Lipstick Apathy
For anyone else who is trying to use DNS Policies and adhere to least privilege, behold: disappointment.

thebigcow
Jan 3, 2001

Bully!
I have a few scripts that I run from the right click menu because they have to be used by non-technical people if I'm out. Current execution policy is RemoteSigned. A recent Windows update installed PowerShell 5.1 and now I get a prompt after running these scripts:

code:
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
[url]http://go.microsoft.com/fwlink/?LinkID=135170.[/url] Do you want to change the execution policy?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"):
Is there a way to turn this off?

Xik
Mar 10, 2011

Dinosaur Gum
If you Unblock-File on the scripts does that resolve the issue? My first guess would be that after the update the scripts are now seen as coming from a remote source, thus won't run with a policy of RemoteSigned?

e: Possibly dumb question, but have you checked you're not actually calling Set-ExecutionPolicy in your scripts somewhere?

thebigcow
Jan 3, 2001

Bully!
Tried Unblocking. Scripts aren't calling the execution policy anywhere. No matter what I select at the prompt it still runs the script. Just weird.

anthonypants
May 6, 2007

by Nyc_Tattoo
Dinosaur Gum
Is your script calling another script?

Briantist
Dec 5, 2003

The Professor does not approve of your post.
Lipstick Apathy

Briantist posted:

NYC folks, come check out Techstravaganza on Fri, Apr 28.

I'll be there, lots of PowerShell MVPs and hopefully some good talks (not just PowerShell stuff).

Only costs :10bux: so probably not worth getting reimbursed at work but hopefully they'll give you the day to go.

Reminder!

skipdogg
Nov 29, 2004
Resident SRT-4 Expert


Not sure if you saw, but Snover is going to be at a Powershell User Group in NYC in June.

Briantist
Dec 5, 2003

The Professor does not approve of your post.
Lipstick Apathy

skipdogg posted:

Not sure if you saw, but Snover is going to be at a Powershell User Group in NYC in June.
Definitely; already RSVP'd :)

Roargasm
Oct 21, 2010

Hate to sound sleazy
But tease me
I don't want it if it's that easy
Hopefully a quick one...I have an array of strings, which are machine names in our environment that can't be live migrated (all *euvb* are video bridges for example). I want to get the entire list of hosts in a hyper-v cluster, then iterate through and see if any of the VMs on the hypervisor match the list of strings. If they do match a string in the array, I don't want to echo the hostname of the hypervisor. If none of the VMs match on a host, it should echo the hostname of the hypervisor back

Struggling with the logic a little bit - I'm comfortable with VMM but I don't know how I'd iterate against the list and say "if any of VMs these match any string in the array, do something." Untested code WIP below

code:
$clusterName = "cluster"
$noLiveMigrateVM = gc c:\vmsNotToMove.txt
$noLiveMigrateVM = $noLiveMigrateVM.Split()

$clusterNodes =  get-scvmhostcluster $clusterName | select -ExpandProperty nodes | sort name

$clusterNodes | % {$hostname = $_.Name; $nodeVMs = $_.VMs | select Name
$canPatchHypervisor = 0

$nodeVMs | % { if ($noLiveMigrateVM -notcontains $_.Name) {
    $canPatchHypervisor = 1
    }
}
if ($canPatchHypervisor = 1) {
    echo $hostname
    }
 }

Roargasm fucked around with this message at 17:12 on Apr 27, 2017

anthonypants
May 6, 2007

by Nyc_Tattoo
Dinosaur Gum

Roargasm posted:

Hopefully a quick one...I have an array of strings, which are machine names in our environment that can't be live migrated (all *euvb* are video bridges for example). I want to get the entire list of hosts in a hyper-v cluster, then iterate through and see if any of the VMs on the hypervisor match the list of strings. If they do match a string in the array, I don't want to echo the hostname of the hypervisor. If none of the VMs match on a host, it should echo the hostname of the hypervisor back

Struggling with the logic a little bit - I'm comfortable with VMM but I don't know how I'd iterate against the list and say "if any of VMs these match any string in the array, do something." Untested code WIP below

code:
$clusterName = "cluster"
$noLiveMigrateVM = gc c:\vmsNotToMove.txt

$clusterNodes =  get-scvmhostcluster $clusterName | select -ExpandProperty nodes | sort name

$clusterNodes | % {$hostname = $_.Name; $nodeVMs = $_.VMs | select Name
$canPatchHypervisor = 0
$nodeVMs | % { if ($_.Name -notmatch $noLiveMigrateVM) {
    $canPatchHypervisor = 1
    }
}
if ($canPatchHypervisor = 1) {
    echo $hostname
    }
 }
Using foreach loops instead of ForEach-Object, your logic looks like this, which might help make it more readable for you
code:
foreach ($node in $clusterNodes) {
  $hostname = $node.Name
  $nodeVMs = $node.VMs | select Name
  $canPatchHypervisor = 0
  foreach ($vm in $nodeVMs) {
    if ($vm.Name -notmatch $noLiveMigrateVM) {
      $canPatchHypervisor = 1
    }
  }
  if ($canPatchHypervisor = 1) {
    echo $hostname
  }
}

anthonypants fucked around with this message at 17:23 on Apr 27, 2017

Roargasm
Oct 21, 2010

Hate to sound sleazy
But tease me
I don't want it if it's that easy
yeah my only real problem right now is this logic:

$nodeVMs | % { if ($noLiveMigrateVM -match "$_.Name") {
$canPatchHypervisor = 0
break
}

I can't find a comparison operator that will return true. Tried $noLiveMigrateVM -containts $_.Name, etc. Always seems to return false

Adbot
ADBOT LOVES YOU

The Fool
Oct 16, 2003


Roargasm posted:

yeah my only real problem right now is this logic:

$nodeVMs | % { if ($noLiveMigrateVM -match "$_.Name") {
$canPatchHypervisor = 0
break
}

I can't find a comparison operator that will return true. Tried $noLiveMigrateVM -containts $_.Name, etc. Always seems to return false

Why is $_.Name surrounded by "'s?

edit: quite test seems to indicate that it doesn't matter, still looks weird.

The Fool fucked around with this message at 17:30 on Apr 27, 2017

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