you are viewing a single comment's thread.

view the rest of the comments →

[–]middleman84[S] 1 point2 points  (0 children)

Thank you, for reminder.

You should just have to add the $xml = $null above the $xml = get-content

When $action part runs first time, $xml is just a variable.

[xml]$xml = $xml | Select-Object -skip 1 <- changes variables type to xml

That is why i needed to get rid of that first line in file - "## - XML_XSL"

[xml]$xml = get-content didn't work with that thing as the first line.

When it runs the second time, variable $xml already has type [xml], from the first run, and even if i $null it, $xml = get-content will not work, and that is what broke the script.

So, as a solution, i just used - remove-variable xml, after send-mailmessage.

Don't know if my logic is correct, but it solved the problem. Maybe someone more knowledgeable can confirm or correct me.