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
2
votes
1 answer

Generated string names in Calculated Properties aren't accepted by select cmdlet

I want to generate the following table: AAA BBB CCC --- --- --- 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 So I write the following code using a foreach loop to generate the column names: $property = @('AAA', 'BBB', 'CCC') |…
Haoshu
  • 832
  • 7
  • 19
2
votes
2 answers

Running help and piping output to Where-Object or Select-Object returns empty rows

Running the command help firewall | Select-Object Category. The result is one column blank Category. The strange thing is that the empty rows number represent the amount of rows that help firewall would result without calling piping it to…
2
votes
1 answer

PowerShell: Identify if disk usage is more than 80%

I'm trying to get the disk usage from all disks and then send out an email if the disk usage is more than 80% for any of the disks. Using the existing articles, I came up with the below but not able to filter out disks with more than 80% usage. Can…
LavaBogg
  • 23
  • 3
2
votes
1 answer

Creating new column in csv using powershell with dynamic values

Hi I am trying to compare two csv and see the delta between them. I want to create a new column in the csv to capture deactivated and new users comparing the old and new data extract. Though I am able to create new column unable to populate values…
2
votes
2 answers

Powershell getting node values of different levels in one Select-Object

Is there a way to do a Select-Object and get the values of nodes of different levels? I need the name and a bunch of fields from the field level but also the globalFormat categoryType. Is there a way to have them in one Select-Object? XML
JY.
  • 25
  • 5
2
votes
1 answer

Split a string into an Object array

I have this string in PowerShell: $filter = "Name;Server;Mounted;ObjectCategory;Guid;WhenChangedUTC;WhenCreatedUTC;ObjectState" I want to split it to get an object array, I tried: $stringArray = $filter.Split(';') but it's a string array. At the…
2
votes
1 answer

Powershell with JSON nested objects - cannot get to a property of property of object

I'm quite new to Powershell and currently I'm trying to convert some data from JSON I downloaded from Solr. The JSON file looks like: { "responseHeader": {"status":0, "QTime":2651}, "InitFailures":{}, "status":{ …
Roman
  • 23
  • 5
2
votes
1 answer

Variable number of fields to output in Select-Object cmdlet

Let's say that I have an Obj with data describing multiple entities. I want to output it like this (CSV, HTML, Format-Table, whatever): Property Code Property descr. Entity1 Entity2 Entity3 abs_de234 abs prop for de 132 412 …
miguello
  • 544
  • 5
  • 15
2
votes
2 answers

Group and select objects from CSV in PowerShell

I have a list of users their device(s) and their managers. The manager and user can be duplicates but the deviceID is unique. How do I get a list so I can send every manager an email to let them know how many and which unit their employees are…
2
votes
1 answer

select-object affecting future out-default streams in a bad way

Powershell seems to tie select cmdlets to the default output stream, and not release it after a command finishes, affecting future command in unexpected ways. It is not consistent in how it does this, which makes generating predictable output…
2
votes
2 answers

PowerShell question with sorting and piping

Hello I am using PowerShell Version 5 I am running a command and it is working but the narrowed search is not returning results. Get-EventLog System -Newest 5 | where {$_.eventID -eq 1074} So I thought oh I only want to see the last 5 objects that…
Brian
  • 55
  • 5
2
votes
2 answers

Powershell JSON pipeline expand multiple values into one column csv

I'm trying to automate some data pipelines with Powershell, but I'm kinda stuck with converting a JSON list to a single cell per row in a CSV file. Hope some of you can help me out. The JSON I get looks like the following: {"result": [ { …
TheCoon
  • 25
  • 1
  • 5
2
votes
3 answers

PS Script is exporting an empty CSVs

I am having a helluva time trying to understand why this script is not working as intended. It is a simple script in which I am attempting to import a CSV, select a few columns that I want, then export the CSV and copy over itself. (Basically we…
2
votes
1 answer

Powershell select unique field

I've got a list of object with some fields. For example, there are three object of my list: Field1 = "aaa" Field2 = 123 Field3 = "ccc" Field1 = "bbb" Field2 = 123 Field3 = "ddd" Field1 = "eee" Field2 = 123 Field3 = "ccc" I need to filter this…
maures
  • 131
  • 1
  • 2
  • 13
2
votes
2 answers

PowerShell: Select custom expression and expand in one operation

I can do something like ls . ` | select @{ Name="Dir"; Expression = { $_ | Split-Path } } ` | select -ExpandProperty Dir to select a custom expression (in this case $_ | Split-Path) into a simple array of values. Is there a way to merge the two…
Tomas Aschan
  • 58,548
  • 56
  • 243
  • 402