Questions tagged [where-object]

26 questions
3
votes
2 answers

Get All AD Groups That Have Blank Managed By Field

I'm trying to get all AD groups that have a blank Managed By Name and the description of the AD group. I'm currently having issues with displaying no results using my filter, but am not sure why. Any help is appreciated. Get-ADGroup -filter * |…
Michael
  • 103
  • 11
2
votes
1 answer

Variable not passing to Where-Object in Powershell

I have tried the "filter" and "param" options from the post -- In powershell passing variable to where-object not working -- with no luck. I am fairly new to powershell since I have not used it since 2014. Can anyone assist me in finding out why the…
user3499299
2
votes
1 answer

PowerShell to query nested child element of hashtable

In PowerShell, I want to get a count of all sports that use balls. The challenge is that they're a level lower than I can access with a direct Where-Object query. Here's the hashtable: $league = @{ school = @{ name = 'Lincoln High School'…
Tony
  • 2,658
  • 2
  • 31
  • 46
1
vote
1 answer

Powershell : Get-ChildItem piped to Select-Object returns null Directory property when selecting directory

I am using the Get-ChildItem cmdlet with the -Recurse parameter to enumerate all files and directories in a specific path. If I run : (Get-ChildItem -Path $Path -Recurse | Where-Object -Property Attributes -Value Directory -EQ).Directory, it returns…
Silloky
  • 147
  • 13
1
vote
0 answers

Use twice the same property name

I need to write a powershell scripts that uses the same property name but from two differents sources. Something a bit similar to such SQL clause "Select UserID from Users,AD where Users.UserID = AD.UserID" I have this code to retrieve all interface…
1
vote
1 answer

PowerShell -notlike not working in Where-Object

I'm struggling with this code: Get-Sensor -Name Ping | where {$_.Tags -like "Kat.A" -or $_.Tags -like "Kat.B" -or $_.Tags -like "Kat.C" -or $_.Tags -like "Kat.D"} | Select-Object Device, Tags I get these values via. Connect-PrtgServer. The output…
1
vote
1 answer

Delete Specific Rows from a CSV File Using PowerShell

The script that I put together does gather the results I need, but I was hoping to utilize a cleaner string. After I gather all the needed information, I export the results to a csv file. There are three specific rows I would like to remove, so I…
1
vote
2 answers

PowerScript Filtering Paradox

Some records have account type N and others have account type G in this example. Why does the filter work in this script: Get-Content "MembersMS.txt" | ForEach-Object {Get-ADUser -Identity $_ -Properties name, uht-IdentityManagement-AccountType} |…
Don
  • 33
  • 3
1
vote
1 answer

Powershell Where-Object returning unmatched values

I have a hash table of PSObjects that holds information about widnows patches and CVE numbers, it takes the format: ID : 2022-Sep InitialRealeaseDate : 13/09/2022 07:00:00 CvrfUrl :…
sailingbikeruk
  • 164
  • 1
  • 8
1
vote
1 answer

McAfee Consumer Product Removal Silent Script

I made a script that works some of the time to remove McAfee products. The issue is that there are sometimes 2 tmp folders that get created. Then, there's a chance that it renames and copies the wrong folder. I'm using Where-Object and LastWriteTime…
Moxadonis
  • 23
  • 4
1
vote
0 answers

Search multiple variables with Where-Object

I'm really hoping somebody can put me out of hours of searching for an answer on this one. I'm running a script against a CSV to locate a set value (servers) in column B and delete the row if they are found. The script works when I pass a single…
neatdoody
  • 11
  • 2
1
vote
1 answer

Is there any way to condense multiple Where-Object conditions in PowerShell?

Novice scripter here and I have a script that connects to multiple file servers and recurses through directories on them looking for files over 90 days old. All that works great. I'm using Get-ChildItem -include and -exclude to filter the files I…
1
vote
1 answer

Filtering and Combining CSV Files via Shared Column Values and Outputting to a New CSV

New to PowerShell, but starting to get the hang of some basics! Appreciate everyone's patience :) I'm trying to match some ZIP code data from one file with matching ZIP codes and Attraction ID's in a second file. File 1 is my 'master' =…
1
vote
1 answer

Get AD User based on their User Profile Description in a Specific AD Group

I'm trying to get all AD users in the AD group 'Fall 2021' where the description is like 'Customer.' I'm currently receiving this error when I run my script. Any help or guidance is much appriciated. Get-ADGroup : Error parsing query: 'Fall 2021'…
Michael
  • 103
  • 11
1
vote
1 answer

Where-Object not finding match but it should

I have Code that imports and excel spreadsheet like this, and I've used this for other excel files fine: $importedExcel = Import-Excel -Path $errorCodeListFilePath -StartRow $startRow return $importedExcel The returned map is stored like…
Michele
  • 3,617
  • 12
  • 47
  • 81
1
2