Questions tagged [pscustomobject]

Shorthand syntax for initializing object properties in powershell

Docs: MSDN - PSCustomObject

Powershell v2.0

$object = New-Object -TypeName PSObject -Property @{  ​
    'Name' = 'Susan'
    'Age' = 32
}

Powershell v3.0

$object = [PSCustomObject]@{  ​
    'Name' = 'Susan'
    'Age' = 32
}

See also:

165 questions
0
votes
1 answer

Converting XML to PSCustomObject

I am trying to convert a standard XML document to that is stored in a series of folder aggregate them together to build an automated patching system. XML document format offer the best mix of flexibility/ease of use. Unfortunately, the XML subsystem…
Nick W.
  • 1,536
  • 3
  • 24
  • 40
0
votes
1 answer

Converting the Excel properties to a Number Format

I have this automation script that will take a .htm file and generate a custom object to be generated into a spreadsheet. Unfortunately, one of the items in my object is a very long number, so when it does get exported to a .xlsx, it looks like…
Huddles18
  • 53
  • 1
  • 6
0
votes
0 answers

Powershell CSV-Export with PSCustomObject

I have a script with which I'm collecting data about users like this: $testObject = [PSCustomObject]@{ username = $username name = $name } Next, I'm getting more info and add to testObject like this: $testObject | Add-Member…
Jordan
  • 1
  • 1
  • 1
0
votes
2 answers

PowerShell PSCustomObject content editing

I import a CSV file successfully and want to change one value in the PSObject array $ds. $ds = Import-Csv test.csv -UseCulture #test.csv content #A;B #11;22 #33;44 $ds $ds.B[1] = 9 $ds This does not work and nothing else either. This should be very…
0
votes
2 answers

How can i convert the output of prnmngr into custom object?

output of cscript prnmngr.vbs -l Server name abcd Printer name \\abcd.com\mailroom Share name mailroom Driver name Canon iR-ADV 4225/4235 UFR II Port name mailroom.com Comment Location Print processor winprint Data type RAW Parameters Attributes…
munish
  • 4,505
  • 14
  • 53
  • 83
0
votes
1 answer

How to get computer name with PsCustomObject?

I currently have a script that pings a list of servers and checks the status of services running on each server. I am wanting to write to log.csv. I want to show which computers are offline and show which service is in the Stopped status. How can I…
Kade Williams
  • 1,041
  • 2
  • 13
  • 28
0
votes
1 answer

PowerShell - Setting a Data Row column type to a custom object

I consider myself fairly new to scripting in PowerShell and I am currently having issues assigning the return value of an API request to a Data Row. The returned value appears to be a custom object: .FRSHEATServiceReqTemplateParam and if…
0
votes
1 answer

How do I convert data using powershell and then grab the users I want

How do I create a variable to store data for further manipulation and then Convert the data coming out of the Excel document into a PSCustomObject and then filter it down to the people I care about Here's what I have so far: $excel = new-object…
Simba
  • 3
  • 3
0
votes
0 answers

Self-referencing in PowerShell

I would like to do some "self-referencing"(?) in PowerShell v3. In a remote script I do: New-Object PSCustomObject -Property @{MyProperty="test"} But I don't know how to access this Property inside this remote script. This Property exist because in…
Goood
  • 21
  • 1
  • 5
0
votes
2 answers

Powershell - WMI error via remote connection

I wrote script in powershell, scrips collects info about status of some system services, for example DHCP service on remote hosts. Sometimes there is a problem with connection to the remote hosts and collect info from WMI. The WMI command…
tester81
  • 533
  • 2
  • 9
  • 28
0
votes
0 answers

PowerShell nested property iteration

Looking for some input on the scripts below. Essentially I'm retrieving some json data with Invoke-WebRequest. I needed to export many of the properties to CSV. The data returned from Invoke-WebRequest is contained in an array: $devicedetails. This…
YEMyslf
  • 407
  • 2
  • 12
  • 27
0
votes
1 answer

Convert array of custom objects to HTML

I am currently trying to feed some XML documents into a script and initialize them as [PSCustomObject]. The XML document needs to be broken into several objects and then added together. Here is my script: [xml]$CourseStructureIn = Get-Content…
Sum1sAdmin
  • 209
  • 1
  • 4
  • 17
0
votes
1 answer

Format-Table ouputting List from pscustomobject in curly braces

I am trying to use a PSCustomObject to store a bunch of information from a remote computer. I can't seem to get the output of Format-Table to work the way i want it. As the picture shows, the list of items in the PSCustom object displays inside…
Fullmetal99012
  • 191
  • 3
  • 12
0
votes
1 answer

Powershell select ignoring column

I am new to Powershell and am trying to get repeating output compatible to be able to use ConvertTo-Html. I have a string in a PSCustomObject as well as some arrays. I am trying to denomalize using the following however the title property is not…
Mark Ruse
  • 387
  • 1
  • 4
  • 12
0
votes
1 answer

Where-Object doesn't find a single instance of a custom object but it finds multiple instances of it. Possible bug?

I'm working on a script that makes an API call and is returned a JSON result and is handled as an array of custom objects in Powershell. One of the properties of the custom object is Status so for each unique status, I wanted to get a count of the…
Rim
  • 195
  • 1
  • 7
1 2 3
10
11