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
3 answers

Get-ADUser password expiration for users in specific OUs

I can get a valid "msDS-UserPasswordExpiryTimeComputed" property for a single user: (([DateTime]::FromFileTime((Get-ADUser $UserName -Properties "msDS-UserPasswordExpiryTimeComputed")."msDS-UserPasswordExpiryTimeComputed"))) But I'm having trouble…
harvey263
  • 76
  • 1
  • 4
2
votes
4 answers

How do I select certain hashtable values but change others in-line in a powershell script

Using piping or other sort of inline notation, I'd like to "select" certain values in a hash table straight through to the result, while changing or setting others. Hash Table I'm starting with a hash table (which, frankly is being used like an…
Code Jockey
  • 6,611
  • 6
  • 33
  • 45
1
vote
0 answers

Powershell array with null value sometimes empty

This happens with Powershell version 5.1.19041.3031. I found something very weird that I cannot explain: $x = $null 'x is null: {0}' -f ($null -eq $x) 'array containing x has size {0}' -f @($x).Count $y = $null | Select-Object 'y is null: {0}' -f…
Silex
  • 1,707
  • 17
  • 24
1
vote
1 answer

Using variable in Select-Object in Powershell

I have a table which is created using Time as the Column names. However if the first row does not have data in certain Hours(column) then the column does not show the column for the rest of the table. Thus, I'm trying to create a dynamic select…
1
vote
1 answer

How to only get one column output for Measure-Object Powershell

I'm trying to get the line count of a csv file. I ran this code to get it: $csvPath = "some.csv" $lineCount = "linecount.csv" Import-Csv $csvPath | Select-Object -Skip 1 | Measure-Object | Export-CSV $lineCount -NoTypeInformation This is the output…
1
vote
1 answer

Using Import-csv and store multiple values of a column as a variable

I have a csv file that has a column named 'art': sequence art last first address city st zip -------- --- ---- ----- ------- ---- -- --- 1 3S Doe John 123 Any Street AnyTown 6 3S Doe John 128 Any Street…
1
vote
1 answer

Powershell: Using import-csv to select rows by column value and export to csv with a number of rows for each unique value

I have a csv that I want to have PowerShell extract 10 rows for each unique value in a column named "art". After the unique art values have been identified, I need sperate csv files for those values. The code I have written has not been working for…
cnjfo672
  • 45
  • 5
1
vote
2 answers

Powershell Select-Object Property multiple comparisons same property

I am using Select-Object to filter a CSV to get the necessary columns. When I use this: $Filter = $Csv | Select-Object ($Csv[0].PSObject.Properties.Name -like "*Results*" it filters all columns and displays everything containing results, this works…
Mufacka
  • 227
  • 1
  • 2
  • 11
1
vote
2 answers

PowerShell regex replace inside a select

I found this code on the internet and it purports to remove all [,],{,} characters from the IPaddress field. However, it does not work (on PowerShell 5.1). I very much like the concept of this and would like to use a working version of…
YorSubs
  • 3,194
  • 7
  • 37
  • 60
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

Display Data on Two Columns Within Excel

I am trying to display data within an Excel document where Column A displays the server name and column B displays the .NET version. I'm running into an issue exporting to a .csv because it says that the file path does not exist. I would like some…
Michael
  • 103
  • 11
1
vote
1 answer

Is there a way to pull a variable value into a select-object expression?

The purpose of this script is to find the Name, directory and last write time of files and output it to a csv file. get-childitem D:\testing -recurse -filter *.txt | select-object Name,DirectoryName,LastWriteTime,…
1
vote
1 answer

Powershell change output object name from datatable

I'm outputting a couple of objects from a data table to a .csv file and wanted to change the object names. This works fine: $dataset.tables[0] | select-object System.ItemName, System.ItemPathDisplay | Export-Csv -Path D:\SEARCH_RESULT.csv…
ColinA
  • 99
  • 1
  • 9
1
vote
1 answer

PowerShell: append string to result of Get-ADUser query

I want to attach a string to a Get-ADUser object. $VALUE = "Something : Else " $RESULT = Get-ADUser -Filter 'givenName -eq "Joe" ' -Property * | Select-Object -Property givenName, Surname, "$VALUE" I got some bracket { } instead of…
post4dirk
  • 313
  • 4
  • 16
1
vote
3 answers

PowerShell Export-CSV to Multiple Paths

I'm trying to export the contents of folders in a directory to a CSV. The issue I'm running into is that I can't figure out how to get the export to 2 different paths. Simply adding another Export-Csv just adds a empty Csv to the 2nd…
duckfeet23
  • 54
  • 8