• Profile picture of Gary

    Gary replied to the topic HtmlWebResponseObject in the forum General PowerShell Q&A 1 day, 3 hours ago

    Not really sure what the difference is.

    Invoke-RESTMethod -Uri $URI -Method Post -Body $postparams | ConvertTo-Json -Depth 20

    Returns the same object, which I convert to JSON to get the same output..

  • Profile picture of Gary

    Gary replied to the topic HtmlWebResponseObject in the forum General PowerShell Q&A 1 day, 8 hours ago

    damn.. just worked it out after posting this..

    I can use this to get a plain formatted text output

    Invoke-WebRequest -Uri $URI -Method POST -Body $postparams | convertfrom-Json | ConvertTo-Json -Depth 20

    I’d still be curious if there is a better way, but this at least lets me read through it enough to work out what I need.

  • Profile picture of Ariana Nesbitt

    Ariana Nesbitt and Profile picture of GaryProfile picture of GaryGary are now friends 1 day, 8 hours ago

  • Profile picture of HARIATTA HESTER

    HARIATTA HESTER and Profile picture of GaryProfile picture of GaryGary are now friends 1 day, 8 hours ago

  • Profile picture of Gary

    Gary started the topic HtmlWebResponseObject in the forum General PowerShell Q&A 1 day, 8 hours ago

    Hi Guys. Is there any way to view HtmlWebResponseObject output in a screen-readable format?

    I’m building a script and have to work with Rest API and right now just want to be able to view the response in a clean way (on screen).

    It’s only for testing purposes, but currently, everything is nested and I have to dig through it each time.

    I’m…[Read more]

  • Profile picture of Gary

    Gary replied to the topic Filter on 2 things in the forum General PowerShell Q&A 2 weeks, 4 days ago

    I finally managed to work out how to filter an array on another array. Below is my script and after feedback, it was decided that they wanted the currently logged on user, not profiles so there is that change.

    Please ignore all the horrible write-hosts, I’ve had headaches recently and it was easier to see the results at a glance.

    I’ll run this a…[Read more]

  • Profile picture of Gary

    Gary replied to the topic Filter on 2 things in the forum General PowerShell Q&A 3 weeks, 2 days ago

    Let me try your order first. I thought that it is something that I should be able to do quite simple but just couldn’t get my head around it.

    I also tried moving the filtering to a few different places but I always ran into the same issue.

  • Profile picture of Gary

    Gary replied to the topic Filter on 2 things in the forum General PowerShell Q&A 3 weeks, 2 days ago

    I had also tried Where but was unable to work it out too.

    Below is my whole script which might explain what I am trying to do better

    $CSV = Import-Csv -Path C:TempWrongOU.csv

    $Computers = Get-ADComputer -Filter * -SearchScope OneLevel -SearchBase $OU | Where -FilterScript {$CSV.DNSHostName -notcontains $_.DNSHostName}

    $object = @()

    Foreach…[Read more]

  • Profile picture of Gary

    Gary started the topic Filter on 2 things in the forum General PowerShell Q&A 3 weeks, 3 days ago

    Hi Guys, I am trying to filter some results based on 2 rules but can’t seem to work it out.

    I have a CSV with 2 columns (Hostname, Profiles) and I want to filter an array based on if the Hostname matches AND if the Profile field is Null/Empty etc

    So I have this that filters out computers that are in my $imported array…[Read more]

  • Profile picture of Gary

    Gary started the topic Formatting Custom Object with Array in the forum General PowerShell Q&A 3 weeks, 3 days ago

    Hi Guys.. I am running through an OU and pinging machines to see if they are ON then collecting the profiles from the computer. I am wanting to then email this information but I’m having some format issues.

    Below is my code so you can see.
    $object = @()

    Foreach ($Computer in $Computers){

    $DNSHostName = $Computer.DNSHostName

    If…[Read more]