PSObject is used for object encapsulation in PowerShell and is used for a consistent view in its environment.
Questions tagged [psobject]
174 questions
0
votes
0 answers
How to return PSObject[] from PowerShell and get value from that PSObject
Execute the PowerShell script and return the output as PSObject[], but unable to get the values from that object.
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
Enable-PSRemoting -Force
$Credentials = New-Object…

THARMA KS
- 21
- 1
- 6
0
votes
1 answer
PSobject as variable
I'm trying to make the 2 functions below working. The thing below, what I find a little strange is: Why is the first Qf function call working but why not the second?
$global:query_output = @()
$global:query_output_filtered = @()
function Q {
…

hexedecimal
- 279
- 1
- 2
- 9
0
votes
2 answers
vb.net casting a powershell output of objectmodel.collection(of PSObject) to a usable VB.net object
I'm using vb.net to remotely run some powershell commands, the output of the powershell.invoke is of the
ObjectModel.Collection(Of PSObject)
Type.
I'd like to cast these to usable vb.net class / collection. When I debug the code, and hover over…

Dennis
- 1,528
- 2
- 16
- 31
0
votes
1 answer
PSObject with relational values - one to manny
want to populate the following PSObject so it can have a one:one or one:many relationship between IPs and hostnames.
$hostobj = New-Object PSOBject
$hostobj | Add-Member -MemberType NoteProperty -Name "ip_address" -Value ""
$hostobj | Add-Member…

Guy Wood
- 255
- 4
- 15
0
votes
0 answers
Cannot perform operation because the runspace is not in the 'Opened' state. Current state of runspace is 'Broken'
I have an example solution(VS 2017, C#) with 2 projects:
Console Application:
Program.cs
Scripts folder:
Aaa.ps1 (reference)
nuget packages:
Npgsql v4.02
System.Management.Automation.dll v10.0.10586
PowerShell Script…

mazury
- 177
- 1
- 2
- 12
0
votes
1 answer
Combine PSObject regex filtered results with initial value names
Need to search some string data in USERS properties inside my AD. I belive that I've made the first step and found them, but I've some troubles with combining the results in one table - I need to determine the CN or Name of the user (something to…

VVl
- 25
- 5
0
votes
1 answer
Deserialize PSObject from JSON to a list in C#
I have an application in C# to display information from Active Directory using PowerShell.
class userps
{
public string Name { get; set; }
public bool Enabled { get; set; }
}
PSObject[] results = pipeline.Invoke().ToArray();
List…

MatDob
- 3
- 2
0
votes
1 answer
Powershell Script is printing out duplicate entries of the same path
My objective is to write a powershell script that will recursively check a file server for any directories that are "x" (insert days) old or older.
I ran into a few issues initially, and I think I got most of it worked out. One of the issues I ran…

Koobah84
- 185
- 2
- 12
0
votes
2 answers
Passing Powershell Arrays by-reference not working as intended
Arrays by reference
Working fine!
The normal way to pass an Array by-reference in PowerShell seems to work fine:
Function Swap-Array ($theArray, $theArrayB, [int]$indexToSwap) {
$temp = $theArrayA[$indexToSwap];
$theArrayA[$indexToSwap] =…

Robert Smith
- 309
- 3
- 10
0
votes
1 answer
Adding a PSObject to Listbox, but displaying only one of the properties
I want to add a PSObject, containing several properties, three to be exact, to a listbox, but only display one of the properties. When I add the entire PSobject to the listbox it shows all the properties like this:
@{Property1="Something",…

Viktor Axén
- 199
- 2
- 11
0
votes
2 answers
PowerShell Process Name using c#
I'm question.
I get process name througth powershell script using c#.
But, i did not get value because process name contains whitespace.
How can I get value to contains whitespace in powershell using c#?

oops
- 1
- 2
0
votes
2 answers
Convert DISM output to PS objects
Can you point me in the right direction, on how do convert this DISM output to Powershell objects so i can use them in my script, to filter on the results ?
dism /Get-WimInfo /WimFile:"E:\_Source\OSD\x64\Windows 10…

BenDK
- 131
- 2
- 7
0
votes
0 answers
PowerShell PSObject change field names before converted to JSON object
I have a project in PowerShell where I created a custom type using the "Add-Type". I wanted to use classes, but I'm limited to the PowerShell version on the system I have to use.
This object gets converted to JSON and is sent out using a REST API. …

JackHubbard
- 11
- 2
0
votes
1 answer
Get-MessageTrace to Exchange Server Using C# Powershell
Currently I have a Powershell script that creates a session with and then queries an Exchange email with the following query:
Get-MessageTrace -StartDate "10/07/2017 12:00 AM" -EndDate "11/06/2017 11:59 PM" -PageSize 5000 -Page $Page | Select…

GameCrazed
- 3
- 4
0
votes
1 answer
How to easily create PSObject from function arguments to return result to pipeline?
Currently I'm doing like that:
function Invoke-Service
{
Param(
[parameter(Mandatory=$true,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)]
[int] $Id,
[parameter(Mandatory=$true,
…

astef
- 8,575
- 4
- 56
- 95