Questions tagged [where-object]

26 questions
0
votes
1 answer

Get-ADGroup with Where-Object cmdlet

I've been trying to create a script to find a missing "Member of" Group in a Group. Can someone help me write the Where-Object cmdlet because I really don't know how this works. This is what I already have: $MissingGroup =…
cosmo_
  • 11
  • 5
0
votes
1 answer

How to delete a folder in the destination folder only if it exists in the source folder

Using Powershell, How can I delete folders in the destination folder only if they exist in the source folder? For example I have the folder structure below and want to delete Folders1 2 and 3 before I copy them from the source folder. I have tried…
HelpMePlz
  • 51
  • 7
0
votes
0 answers

How to copy a folder and overwrite the full contents of the destination folder with powershell?

I want to copy folder 1 from the source directory to the destination directory however folder 1 is always a randomly generated number. Source/Folder A: folder 1 (random number) file1.txt file2.txt Destination/Folder A: …
HelpMePlz
  • 51
  • 7
0
votes
0 answers

unable to use where-object as value is nested in array with powershell

I'm currently working through a csv of Sharepoint AuditData and trying to evaluate several fields that are nested in the audit data field. I've tried all the Usual $_.AuditData.CreatedDate etc. but can't figure out how to query the data thats nested…
0
votes
0 answers

How to user where-object with a variable input

Ok so I am trying to use a variable to make up a where statement on a get-aduser command. This is what I am trying to emulate which works: get-aduser -filter * | where { $_.DistinguishedName -like "*Users,DC*" } Note the are asterix before and…
EdC
  • 1
  • 1
0
votes
0 answers

Powershell how to filter objects based on child objects of child objects

In powershell I've got a COM object which has several child COM objects which themselves have child com objects. I want to be able to get the top level object if the child of the child has a particular property. Unfortunately many of the objects…
Bee_Riii
  • 814
  • 8
  • 26
0
votes
0 answers

Find mailboxes Where-Object {$_.InPlaceHold not in $ArrayOfValues} [PowerShell]

I'm trying to build out a script that adds Exchange Online mailboxes that do not have an InPlaceHold property that matches the GUID of one of multiple Security and Compliance Retention Policies (this list needs to dynamically change as more and more…
0
votes
0 answers

Where-Object : The specified operator requires both the -Property and -Value parameters. Provide values for both parameters, and then try the

I'm doing the following powershell line, and for some reason it's finding a syntax error with it, but I'm not sure why, and I can't find it in an internet search: $eventInitTerminate = Get-WinEvent -FilterHashtable…
Michele
  • 3,617
  • 12
  • 47
  • 81
0
votes
0 answers

Unexpected output from where-object

In PowerShell, this command: Get-NetIPConfiguration | where-object {$_.IPv4Address.IPAddress -match '172.20'} Is yielding this output: InterfaceAlias : Wi-Fi InterfaceIndex : 24 InterfaceDescription : Intel(R) Wi-Fi 6 AX201…
0
votes
1 answer

Foreach with Where-Object not yielding correct results

I have the following code: $ErrCodes = Get-AlarmIDs_XML -fileNamePath $Paper_Dialog_FullBasePath $excelDevice = Get_ErrorCodes -errorCodeListFilePath $outFilePath -ws "DEVICE COMPONENT MAP" foreach…
Michele
  • 3,617
  • 12
  • 47
  • 81
-1
votes
2 answers

Ho do I wrap Where-Object in a helper filter?

I have this code: $resultset = $stuff | Where-Object { $_.Prop1.SubProp7 -eq 'SearchString' } Very similar code is repeated quite a few times. (in a Pester test). How can I wrap that code in a simple filter helper? filter…
Martin Ba
  • 37,187
  • 33
  • 183
  • 337
1
2