• For this example, I don't really see a point of a pester test?

    Since your pester test makes the change, the test becomes the script itself, no?

    And in this example, you'd have to know in advance what the value for the Registry Key was, to know if your function actually did anything. If it was already set to 0, but your function failed for whatever reason, it would return a false positive.
    Personally, if I wrote a script for this, I would much rather check what the value was, change it if needed, and then check it afterwards so I know that it was changed.

    Maybe I'm missing the point, but since Pestering actually carries out the work that it should only be *testing*, what is the actual point?
    Maybe if I'm only getting back information, but not when it actually makes changes(?)...

  • Panzerbjrn liked comment of Marc van Gorp on PowerShell integration tests with Pester. (So far, Marc van Gorp has 1 likes for this comment.) 2 years ago

  • Well, yes, but the content is just one long string, hence my question...

    $BlobCSV.Content might technically be an array, but [0] has everything...

  • Thanks for taking the time to reply 🙂
    Yes, I do have a url, it was late and I forgot to include it here...

    $BlobCSV = Invoke-WebRequest -Uri $url -Headers $AuthHeaders
    IsPublic IsSerial Name                                     BaseType
    -------- -------- ----                                     --------
    True     False    WebResponseObject                        System.Object
    IsPublic IsSerial Name                                     BaseType
    -------- -------- ----                                     --------
    True     True     String                                   System.Object
    IsPublic IsSerial Name                                     BaseType
    -------- -------- ----                                     --------
    True     True     Byte[]                                   System.Array

    I guess these are all the types you'd expect.

    I guess this isn't helped by the billing report having two lines with text before the CSV columns start on line 3...

  • Thanks for the useful article.

    How would you go about getting the content you receive into a variable, and then working with it from there?

    Specifically, I'm trying to get our Azure Billing Report, which is a CSV file, and then write it to Azure blob storage. As I am trying to do this from an Azure function, I don't really have the luxury of writing to a file first.

    When I do

    Invoke-WebRequest -Outfile Billing.csv

     everything is fine, and I get a nice CSV.

    When I do

    $BlobCSV = Invoke-WebRequest

    all I get is one big string of text.

    Any ideas?

  • Thanks. Although I think I'll do it in PowerShell instead 😉

  • Panzerbjrn's profile was updated 3 years, 1 month ago

  • This doesn't work:

    $new = $old = Get-DnsServerResourceRecord -ComputerName dc -ZoneName mylab.local -Name MYSQL


    This just creates a link to the same object, so you are not able to update the old object.

  • Panzerbjrn became a registered member 5 years, 5 months ago

© 4sysops 2006 - 2022


Please ask IT administration questions in the forums. Any other messages are welcome.


Log in with your credentials


Forgot your details?

Create Account