Questions tagged [psobject]

PSObject is used for object encapsulation in PowerShell and is used for a consistent view in its environment.

174 questions
0
votes
2 answers

Create a custom object referencing other objects

I am trying to create a new custom object with data input from another object. $clusters = Get-EMRClusters $runningclusters = $clusters | Where-Object { $_.Status.State -eq "Running" -or $_.Status.State -eq "Waiting" } $runningclusters…
Montel Edwards
  • 400
  • 5
  • 14
0
votes
1 answer

Powershell 2.0 random $null addition from Add-Member

My goal is to save some info into a variable that later will be written out ($Server). I have created a cmdlet that gets some info from the CPU, which gives me the result i want to add into my server variable. When i add it i get a $null value. PS…
Mike
  • 850
  • 10
  • 33
0
votes
1 answer

Resolving hostnames on network using PowerShell

8 | foreach { New-Object PSObject -Prop @{ Address ="192.168.1.$_"; Status = (Test-Connection "192.168.1.$_" -Quiet -Count 1); try {HostName=[System.Net.Dns]::GetHostEntry("192.168.1.$_").HostName} catch…
0
votes
1 answer

Boolean NoteProperty becomes an Array

The title says it all single boolean value becomes an array when assigned to a NoteProperty using Add-Member or using splatting. PSVersion: 5.0.1xx I have what I consider a strange problem. I am creating a PSObject with one of the NoteProperty…
kgjac
  • 5
  • 1
  • 4
0
votes
2 answers

Powershell WMI vs CIM same object returns different properties attributes

I'm trying to convert a WMI based script to CIM, this script is able to inject an IP Address to an Hyper-V Virtual Mahine Original Script is : http://www.ravichaganti.com/blog/?p=2766 In my case, I've converted the WMI to CIM sentences like…
Uh Trog
  • 41
  • 1
  • 9
0
votes
2 answers

PowerShell Export-Csv Picks Up Last Row Only

I know this question has been asked before, but I'm having a really hard time applying the solutions of others to my situation. Please provide both the conceptual and technical (code) explanations to your answer as I need to understand how this…
Chiramisu
  • 4,687
  • 7
  • 47
  • 77
0
votes
1 answer

Collection to CSV output

Is there a nice way to convert Collection to CSV output? Collection psResult = pipeline.Invoke(); Tried pipeline.ToCsv(); Also psResult.ToCsv() Any ideas?
Amir Katz
  • 1,027
  • 1
  • 10
  • 24
0
votes
0 answers

Issues with enumerating PSObject Collections in CSHTML but not CS

I'm writing a small web app that requires I display the properties of a collection of PSObject on an ASP.NET C# Web Page. In my controller class, a .cs file, I can access the First() method of a collection as such: Collection test = new…
Daenks
  • 1
  • 1
0
votes
0 answers

Iterate PSObject hashtable in C#

One of the properties (identity) in my PSObject object is a hashtable like this which is returned from PowerShell: @{name=something; Number=87354} This is what I'm trying to do: foreach (PSObject ticket in tickets) { var a =…
90abyss
  • 7,037
  • 19
  • 63
  • 94
0
votes
1 answer

I created function to run script of "Power Shell script"

I created function to run script of "Power Shell script". I use Pipeline and Runspace ro run script (ex: power shell get-service) and run 1.000.000 times script “get-service” I see: - when run 1 script (1 pipeline and 1 runspace) then ram of…
0
votes
1 answer

PowerShell cmd in c# call Invoke return no PsObject for specific user email list

i try to get a list of email for specific user in exchange server using this PowerShell command via c# "get-mailbox -Identity username -resultsize unlimited | select Name -expand EmailAddresses | Select SmtpAddress" this work in powershell…
DarkVision
  • 1,373
  • 3
  • 20
  • 33
0
votes
1 answer

Custom PowerShell Object Property Issue

I'm attempting to create a custom PowerShell object using data from the WebAdministration module for IIS7. The object should capture the ClientIPAddress and SiteID from the GetExecuteRequest WmiMethod for Worker Processes in IIS. $p = Get-WmiObject…
Robert
  • 1
  • 1
0
votes
1 answer

Powershell: Dynamically Convert Get-WMIObject to PSObject

The majority of code examples I can find for working with Powershell and C# involve the use of PSobjects to return data from the Powershell scripts. A large amount of examples on creating a PSObject involve taking data from Get-WMIObject and…
0
votes
1 answer

Sort Properties of Object Powershell

All i'm using this code to get data from SharePoint List and export it to txt file as you see i'm using New-Object PSObject to get this my question is how can i sort the the properties by the name i gave or how to export this items sorted by…
0
votes
1 answer

powershell multi valued variables or sql table

i'm wanting to write data into memory only for a temp time. the format is essentially the same as an sql table with say 5 columns and 1,000 rows, give or take. simply i want to store this data and run queries against it to make calculations, sorting…
user512628
  • 139
  • 2
  • 9
1 2 3
11
12