Questions tagged [select-object]

PowerShell cmdlet that selects objects or object properties.

The Select-Object cmdlet selects specified properties of an object or set of objects. It can also select unique objects, a specified number of objects, or objects in a specified position in an array.

https://technet.microsoft.com/en-us/library/hh849895.aspx

109 questions
0
votes
3 answers

how to expand multiple properties when output contains @{, }?

I know there's a number of posts about expanding a single property and hopefully this is an easy one but my output looks like this as a result of a select-string -simplematch @{Brand=Volkswagen; Model=Passat} @{Brand=Ford; Model=Mondeo} But how do…
kkp0897
  • 19
  • 1
  • 1
0
votes
1 answer

How to find the title for a PDF from the metadata?

How can I get the title for a PDF file after having renamed the file itself? PSPath : Microsoft.PowerShell.Core\FileSystem::/home/nicholas/to/99.pdf PSParentPath :…
0
votes
1 answer

How do I select properties with a variable in Powershell Select-Object

Test 1 works as expected. Why doesn't Test 2 work the same way? $user="bsimms" Write-Host "test 1" $test1out=Get-ADUser $user -Properties * | Select-Object -Property Name, samAccountName, EmployeeID Write-Host "test1: $test1out" $myitems="Name,…
DanFox
  • 3
  • 2
0
votes
1 answer

Add Name of EC2 in report AWS Backup Powershell

I need to make a report with Powershell-AWS Sdk for AWS Backup. Actually i have the current report : Report exemple screenshot I want to add column on the left with Name Instance TAG for each raw match with VolumeId for more friendly use and read…
0
votes
0 answers

Using Select-Object in a script moves on before Select-Object is done

With this code: Get-ADUser -Filter {samaccountname -like "jsmith*"} | select samaccountname Read-Host "what's up" Why does my output always ask "what's up" before giving me the list of AD Users? The issue only occurs if I use select.
DragonKing
  • 21
  • 2
0
votes
1 answer

How to use Sort-Object and Where-Object in Select-Object in PowerShell?

I'm writing a PowerShell script for Azure PowerShell 3.1.0: Get content from JSON Looping through the content based on a condition where MigratedFlag='Y' and sort ascending onOrderNo Executing the SQL file from Location using Invoke-Sqlcmd If my…
0
votes
3 answers

Powershell - Search json tree

I have a json structure in a file my.json that looks similar to below: { "key1":{ "key1A":{ "someKey":"someValue" }, "key1B":{ "someKey":"someValue" } }, "key2":{ "key2A":{ …
Bernie Lenz
  • 1,967
  • 23
  • 45
0
votes
2 answers

Powershell script is missing property in result

I am not sure what is wrong with the script. I have a 3 column csv file that consists of Name,Count,Owner. The goal is to get the highest count of each name, then output all 3 columns, however the Owner column is not outputting. I am only getting…
0
votes
2 answers

In a JSON array, how to search for a certain record returned by ConvertFrom-Json?

With Powershell 6 I am able to download a file in JSON format with: PS C:\> Invoke-WebRequest https://login.microsoftonline.com/common/discovery/v2.0/keys | >> ConvertFrom-Json | >> Select-Object -expand keys kty : RSA use : sig kid :…
Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
0
votes
1 answer

Custom PSObject is returning Array instead of the Object properties

I'm having a difficult time figuring out where this code is breaking, and why Select-Object is not returning the desired object properties as output. Any input into what is happening here, or any potential fixes are greatly appreciated. I'm…
Duck
  • 91
  • 7
0
votes
1 answer

Powershell Modify Select-Object Property Before Output

How would I go about removing the leading "{Storage consumed:, " and the trailing "}" from the DiskAllocation property of this Select-Object so that only the size remains? For Example: {Storage consumed:, 48.62 MB} becomes 48.62 MB I know that I…
TechFA
  • 129
  • 1
  • 9
0
votes
1 answer

Select-Object calculated property from variable

I'm aware that we can specify a comma-separated string[] of properties in a variable to the Select-Object -Property parameter. However, I'm trying to include calculated properties in that variable. Tried adding it by enclosing them in single-quotes…
Karthick Ganesan
  • 375
  • 4
  • 11
0
votes
3 answers

How do I add a variable as a column value in a result set?

I have a variable that loops through values from a CSV file. As the loop returns result sets for each value I have in the CSV, I also want that value (the variable) returned in the result set. I tried to add my variable, $user, in my Select…
0
votes
1 answer

Using Select-Object and Where-Object in same sentence with PowerShell

I'm new using PowerShell, and I'm trying to select some fields from Active Directory that are like some strings, let me explain: This is my code so far: $csv = Import-Csv C:\Users\barreola\Desktop\test_AD.csv $IS =…
Bryan Arreola
  • 197
  • 1
  • 6
  • 22
0
votes
1 answer

PowerShell problem using Select-Object with C# cmdlet

I've written a simple C# cmdlet, let's call it Get-Data, that returns an array of objects. protected override void ProcessRecord() { base.ProcessRecord(); DummyClass[] refs = new DummyClass[2]; refs[0] = new DummyClass("A", "big"); …
scantrell
  • 111
  • 1
  • 6