Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#-->The first 4 lines are the same for all attempts. Between attempts I exited PowerShell.
- I know I could use the Remove-Variable command too.<--#>
- $Date = Get-Date -DisplayHint Date
- Get-ADUser -Filter * -SearchBase "OU=Users,DC=Domain" -SearchScope OneLevel -Properties sAMAccountName |
- Select-Object @{Name="User ID";Expression={$_."sAMAccountName"}}, @{Name="Date";Expression={$Date}} |
- Export-Csv "C:\File.csv" -NoTypeInformation
- #-->First Attempt<--#
- $Import = Import-Csv C:\File.csv
- $Sample = Get-Random -InputObject $Import -Count 20
- $List = $Import -ne $Sample
- #This shows 20.
- $Sample.Count
- #These both show the same number instead of $List being 20 less than $Import.
- $Import.Count
- $List.Count
- #-->Second Attempt<--#
- $Import = Get-Content C:\File.csv
- $Sample = Get-Random -InputObject $Import -Count 20
- $List = $Import -ne $Sample
- #This shows 20.
- $Sample.Count
- #These both show the same number instead of $List being 20 less than $Import.
- $Import.Count
- $List.Count
- #-->Third Attempt<--#
- [System.Collections.ArrayList]$Import = Import-Csv C:\File.csv
- [System.Collections.ArrayList]$Sample = Get-Random -InputObject $Import -Count 20
- [System.Collections.ArrayList]$List = $Import -ne $Sample
- #This shows 20.
- $Sample.Count
- #These both show the same number instead of $List being 20 less than $Import.
- $Import.Count
- $List.Count
- #-->Fourth Attempt<--#
- [System.Collections.ArrayList]$Import = Import-Csv C:\File.csv
- [System.Collections.ArrayList]$Sample = Get-Random -InputObject $Import -Count 20
- [System.Collections.ArrayList]$List = $Import.Remove($Sample)
- #This shows 20.
- $Sample.Count
- #This shows 1000.
- $Import.Count
- #This shows 0.
- $List.Count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement