PSObject is used for object encapsulation in PowerShell and is used for a consistent view in its environment.
Questions tagged [psobject]
174 questions
1
vote
0 answers
C# Pipeline.Invoke() not returning powershell collection
On Windows 10, in C# I am trying to call a powershell script via Pipeline.Invoke() to retrieve all the disks on a network server, for each server on a network. But can't get it to return the data to C# when there are multiple disks on a server.
I…

Mark Worrall
- 290
- 3
- 9
1
vote
1 answer
Array of psobjects missing members in scanning TCP and UDP ports script
I'm running this script which scans ports, outputs the result to a psobject. It first checks if the port is TCP or UDP, then it runs a switch depending on whether the port is 3389, 443 or something else. If it's 3389 or 443, it uses the…

Aziz
- 283
- 1
- 14
1
vote
2 answers
Adding array elements to a PSObject
Preface: I haven't any formal training with script writing. So I'm sure many of you will be banging you head against the table wondering what I'm doing.
I am working to gather information on our current catalog of Teams sites, and respective site…

Dalebert
- 35
- 4
1
vote
2 answers
How to extract PowerShell results to DataTable in vb.net
I would like to extract the PowerShell output and extract the data and store in DataTable in VB.NET, I want to display the output in a GridView
I need extract the column and value from the PowerShell output in VB.NET
Here is the…

user1172579
- 575
- 1
- 7
- 22
1
vote
2 answers
Calculated properties in pipeline expressions return null in jobs when passed using a PSObject
I am trying to pass a hashtable of calculated properties in to a query, for use with Select-Object. It works when run in the console. I can confirm that the job is reading the hashtable as it lists the selected properties in the result, yet all of…

Arbiter
- 450
- 5
- 26
1
vote
1 answer
How to ouput Powercfg /availablesleepstates into objects using powershell
Command line output:
C:\powercfg -availablesleepstates
The following sleep states are available on this system:
Standby (S3)
Hibernate
Hybrid Sleep
Fast Startup
The following sleep states are not available on this system:
…

Premo103
- 11
- 2
1
vote
1 answer
How to convert a JSON string to PSObject?
I want to write a PowerShell function in C#. During the process I receive a string with JSON content.
My sample json content is:
string json = "{'TestNr':{'Name':'CSHARP', 'Description':'Test Descriptiopn'}}"
This string should be converted to a…

Alex_P
- 2,580
- 3
- 22
- 37
1
vote
1 answer
Why can't i return all cimsession functions from Powershell.Invoke() method in c#
I'm running New-CimSession command from both Powershell and C#. When I run it on Powershell, CimSession variable has a lot of functions such as TestConnection(), CreateInstance etc.. Picture is below.
But, CimSession variable type of PSObject…

Emre Berk AKIRMAK
- 13
- 3
1
vote
1 answer
HOW TO output the values of an array to a text file in a specified format
I'm using DBATools Module Invoke-DBQQuery ( based on Invoke-SQLCMD2) to query a SQL database.
The query returns single record as a PSObject called $Results that looks like this...
FileName : C12345
BADGENUMBER : BADGENUMBER=12345
LASTNAME…

Mark Buckley
- 267
- 1
- 4
- 14
1
vote
3 answers
Looping through properties inside a PSObject in PowerShell (from json)
After opening a .json file in PowerShell, I've got a new PSObject called $json_sitesandsnets. Ultimately what I want to do is loop through each Site (Orlando, Denver), and loop through each of their subnets, and do stuff. Initially, I need to create…

stackDram
- 13
- 1
- 4
1
vote
2 answers
Select-Object Data Failure From Succesful Invoke-RestMethod
I have a working call to a rest service using Invoke-RestMethod -Uri https://.... The call's result, in JSON, can be piped the data to Format-Table -Property ... and data is shown.
But when Select-Object -Property ... is used after the invoke with…

ΩmegaMan
- 29,542
- 12
- 100
- 122
1
vote
1 answer
powershell return each drive empty space of machine in c#
I want to get empty space of every drive of server with powershell using C#
this is the powershell script which works fine
Get-PSDrive |Format-Table
what I want is to take output of this script and show it on UI
What I tried till now.
string…

Ameya Deshpande
- 3,580
- 4
- 30
- 46
1
vote
2 answers
Mass test-connection powershell
Well, I have problem with Test-Connection function in PowerShell.
I have a csv file with column Server name and IPAddress. I need to create connection report with information Server name, IPAddress, Result. How could I add information about column…

Maciej Obidziński
- 11
- 1
1
vote
1 answer
How to to Convert PSObject to Stream output or DataTable using C# Powershell System.Management.Automation
I need to convert PowerShell PSObject to stream in a sameway the way PowerShell does. PowerShell also provides the output on standard stream in generic way.
e.g. $PSVersionTable only outputs 2 column ( Name, Value ) and not the whole Hashtable.
So,…

Usman
- 2,742
- 4
- 44
- 82
1
vote
0 answers
Printing Powershell array properties in do/until loop displays blank lines after first iteration of loop
I am trying to display unique values from each column in an array that is generated from a CSV file.
CSV file…

Joey
- 433
- 2
- 6