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

Can't show specific properties when connecting to office 365

so I'am writing a script to automate connection to o365 and exchange online, i was able to do that, then the script spouse to show me specific properties and from some reason it's selection only one property $getusrname = read-host "what is the…
WebsGhost
  • 107
  • 1
  • 14
0
votes
1 answer

PoweShell: Casting the data type for properties in Select-Object

I'm looking for a more efficient method (for both typing time and performance) of casting data types during a PowerShell Select-Object. Currently, I am wrapping each individual property in an expression to cast the data type. I'm confident this…
Arbiter
  • 450
  • 5
  • 26
0
votes
2 answers

Powershell check if file exists and replace it with new copy

I'm trying to check if a directory exists, and if it does replace all files in that directory with updated files from another directory. $path = "C:\mypath\config" if([System.IO.Directory]::Exists($path)){ $files = Get-ChildItem -Path $path |…
Gary Henning
  • 80
  • 1
  • 2
  • 10
0
votes
2 answers

How do I input the SamAccountName from get-aduser?

I've been scrambling around looking for examples of how -inputobject is used, and I cannot seem to find any. I've never touched powershell before, but when I recently started this job, and was told that this is a script we used, I couldn't help but…
Spook City
  • 45
  • 6
0
votes
3 answers

Format CSV From Object

I am trying to figure out how to create a .csv from a PowerShell object that has the appropriate columns. I want to create a .csv file with three columns (User ID, Country, Count). It also needs to sort by User ID and then Country (A to Z). In the…
0
votes
1 answer

Trying to limit string to 8000 characters before using data and I get nulls returned

Writing some code to do an insert from rest API into database. One of the fields needs to be limited to 8000 characters which I am having trouble doing. Tried lots of googling. $searchResultsResponse = Invoke-RestMethod -Method GET -Uri…
Kez
  • 57
  • 1
  • 8
0
votes
1 answer

Compare objects and export the difference

I would like to make a script that compares O365 tenant settings. Reading them is fine, now I would like to make some kind of difference object. A related question is here, but no answer. Powershell Compare-Object and getting the Differences into a…
vilmarci
  • 451
  • 10
  • 31
0
votes
3 answers

Trying to use Powershell to import information from a csv but unfortunately some of the results come out wrong

$AuditSuccess = Import-Csv -Path G:\LabLog.csv | Where-Object { $_.Keywords -like "Audit Success" } | Measure-Object | Select-Object count $AuditFailure = Import-Csv -Path G:\LabLog.csv | Where-Object { $_.Keywords -like "Audit Failure" } |…
0
votes
0 answers

Select-Object -ExpandProperty issue

I have run into an issue that the output from 2 users are not identical when running a PowerShell script as belew. Does anyone how to fix the issue for user B to get the same result of User A ? Get-Mailbox hkgbsdis-3130501 | Select-Object…
0
votes
1 answer

CSV data from PowerShell Export-Csv contains select clause on first line

I’m pushing data from Get-ChildItem to a csv, via some Where-Object and Select-Object directives as below. The problem is that the first line of the csv contains the Select clause itself (eg literally { “This part” + $_.AndThisBit }. Not sure why…
sasfrog
  • 2,410
  • 1
  • 17
  • 28
0
votes
1 answer

Copying Only The Last File Of Each Group Of The Same File Using PowerShell

I ran into an issue building the Bamboo deployment of a legacy application. The application has many version of the same DLLs, so when they are copied over as artifacts during the deployment process, they needlessly overwrite each other, adding an…
Ethilium
  • 1,224
  • 1
  • 14
  • 20
0
votes
1 answer

Powershell .CSV values piped to select-objects returns empty records?

When i use import-csv to retrieve data from a .csv file I'm able to retrieve the data in the file in the console pane using Import-CSV: import-csv \\TestPath\licenses_v2.csv However, when i pipe that output to a select-object statement the same…
Lee
  • 95
  • 1
  • 13
0
votes
1 answer

Powershell Select-Object -expandproperty strange behavior when input is array and contains array properties

I am trying to build a report file collecting data from various sources. I have built a reporting structure like this: $Data = import-csv "some CSV FILE" <# csv file must look like this hostname,IP server1,192.168.1.20 #> Then I am building an…
IonutN
  • 91
  • 1
  • 10
0
votes
1 answer

Why is this not working? - Trying to save properties in a variable for use multiple times in a function

I am trying to find a way to save the properties for a select statement in PowerShell but it isn't working. I haven't found a way to make an entire statement a literal so that it isn't reviewed until the variable is opened. Here is what…
J.C.
  • 143
  • 1
  • 8
0
votes
1 answer

Get Selected Properties of Parameters of a Powershell CmdLet

Given any Cmdlet (Powershell v3) I want to get a list of the parameters with only selected properties (e.g. name and type). The output as JSON should something like: [ { "Name": "Path", "ParameterType": …
Marc
  • 13,011
  • 11
  • 78
  • 98