1

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.

Jack
  • 11
  • 1
  • Does this answer your question? [What's the best way to determine the location of the current PowerShell script?](https://stackoverflow.com/questions/5466329/whats-the-best-way-to-determine-the-location-of-the-current-powershell-script) – Scepticalist Nov 28 '22 at 15:58
  • Take a look at this. I would use the 2nd answer: https://stackoverflow.com/questions/6500277/how-can-i-create-a-powershell-script-to-copy-a-file-to-a-usb-flash-drive – shadow2020 Nov 28 '22 at 16:33

0 Answers0