• 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(?)...

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

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

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

    0
  • 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
    $BlobCSV.GetType()
    
    IsPublic IsSerial Name                                     BaseType
    -------- -------- ----                                     --------
    True     False    WebResponseObject                        System.Object
    
    $BlobCSV.RawContent.GetType()
    
    IsPublic IsSerial Name                                     BaseType
    -------- -------- ----                                     --------
    True     True     String                                   System.Object
    
    $BlobCSV.Content.GetType()
    
    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...

    0
  • 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?

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

    0
  • Panzerbjrn's profile was updated 1 year, 8 months ago

    0
  • 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.

    0
  • Panzerbjrn became a registered member 3 years, 11 months ago

    0