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
1 answer
Unable to pass PSObject as an argument to to Start-Process
I had a requirement to read an input file, which is an xml (as below)
Server1
Database1
…

Adarsh
- 52
- 7
1
vote
0 answers
C# PSObject Members.Value
I am trying to get on a PSObject "undervalue" in my GUI, but I don't have a clue how to get this into a variable.
The code looks like this:
foreach (PSObject outputItem in JobSession)
{
if (outputItem != null)
{
…

Anri
- 11
- 1
1
vote
1 answer
Listbox Bound to a PSObject list DisplayMember not working
I have a form with a listbox on it. In this listbox I want to put PSObjects that have these members: Name, Location, ID.
I have created a variable: $list that holds all the PSObjects and I want to bind $list to the $listbox so that anytime $list is…

CuriousOne
- 922
- 1
- 10
- 26
1
vote
1 answer
Bulk importing JSON into SQL Server
I need to bulk import data into a SQL Server database.
My JSON looks like this:
$projectsJSON = @"
[
{
"id": 35,
"created_at": "2016-01-12T11:40:36+01:00",
"customer_id": 34,
"name": ".com",
"note": …

Mara
- 371
- 5
- 16
1
vote
1 answer
Select-Object & empty variable
I'm trying to build an boot report for my domain computers and send it automatically by mail.
though, I'm having trouble to put it into a variable to send using Send-MailMessage function.
Here's the piece of code:
foreach ($computer in…

Sidney Morais
- 21
- 5
1
vote
1 answer
Get values from Invoke-RestMethod PSobject
I am using Invoke-RestMethod to pull employee data from our HRIS (human resource information system):
$employee = Invoke-RestMethod -Method Get -Headers $headers -Uri $URI -ContentType 'application/json'
It returns this PSobject and I am having…

Brian
- 622
- 10
- 29
1
vote
1 answer
How do I/do I need to dispose of custom PSObjects?
Do I need to dispose of the object returned from this function? I don't see a Dispose method on a PSObject, but that doesn't necessarily mean the object can't/shouldn't be disposed of. I've searched google, and can't find anything related to…

gangelo
- 3,034
- 4
- 29
- 43
1
vote
1 answer
Automapper mapping Powershell PSObject
What's the easiest method to map from a a PSObject returned from a PowerShell host in C#?
Example program (minus the actual mapping):
class SOResult
{
public DateTime A { get; set; }
public string B { get; set; }
}
var script = "@{ A =…
user111013
1
vote
1 answer
PowerShell PSObject confusion between -pass & -passthru
function getinfo {
$strComputer = "localhost"
$colItems = GWMI -cl "Win32_NetworkAdapterConfiguration" -name "root\CimV2" -comp $strComputer -filter "IpEnabled = TRUE"
$Items1 = $colItems | Select DHCPServer, Caption, DNSHostName,…

hdhruna
- 865
- 6
- 15
1
vote
2 answers
PSObject -Property with conditions
I would like to put conditions in this part of my code:
$objInfos = New-Object PSObject -Property @{
Dossier = [string]"$($logs[0])"
"Taille totale" = [double]$logs[1]
"Categorie…

Kikopu
- 155
- 1
- 2
- 10
1
vote
1 answer
convert powershell Psobject to New-object
I have made a function that returns a custom psobject, but when I am trying to use the "." to get the properties of the object noting happens, also the pipe isnt working in this type of object.
There is a way to convert this object to the one…

kimo pryvt
- 483
- 1
- 7
- 25
1
vote
0 answers
C# powershell objects as a datasource
Bare bones of the problem:
I am trying to populate a ComboBox, or even a ListBox for Windows Forms and for standard arrays and class definitions, it works great using DataSources and the related ValueMember and DisplayMember.
The problem arises…

John King
- 11
- 2
1
vote
1 answer
Add new values to PSObject - Is this the best approach?
I have the following code and it works. But I was wondering if this was the best approach as it repeats the structure over and over again.
$Computers = Get-Content -Path C:\scripts\Computers.txt
$AllComputers = @()
foreach ($machine in $Computers)…

Ninja Cowgirl
- 10,421
- 8
- 33
- 41
1
vote
1 answer
Powershell Invoke-RestMethod To Return JSON
I am using PowerShell to run a php script on a daily basis. I can't seem to get the json return back from Invoke-RestMethod. How can that be accomplished?
Here is the code I am using:
$limit = 200;
for ($i=1; $i -le $limit; $i++)
{ …

ninedoors
- 126
- 4
- 17
1
vote
0 answers
Can a PSObject have properties that are PSObjects?
I have a C# Cmdlet that interacts with a REST service, deserializing JSON as dynamic objects (ExpandoObject). When an expando is passed to WriteObject it gets written to the pipeline as a dictionary so I am converting it to a PSObject like so in…

dkackman
- 15,179
- 13
- 69
- 123