I am trying to write a powershell script which takes system information and converts it into a HTML table. I'm very new to this but have managed to get the script to write as a HTML table. I've also managed to make the script an executable file which is great. The issue is, I want to use this script on other computers through different usb sticks. Currently if I write:
$Report = ConvertTo-HTML -Body "$ComputerName $OSinfo $ProcessInfo $BiosInfo $DiscInfo $ServicesInfo" -Head $header -Title "Computer Information Report" -PostContent "
$Report | Out-File C:\Users\John\Desktop\Test.html
It will save the output as a html on my desktop. When I plug the USB into another computer however, this doesn't work as the file path has changed. How can I get HTML report to write to the USB stick, keeping in mind the USB letter changes constantly?
I've looked into this a lot but cannot find an answer to this specific question. I know on CMD I can write \Test.html and it will save directly to the USB stick location but I cannot get this to work on Powershell.
Thanks
I've tried removing the drive letter and also ".." but neither works.