I am using PowerShell Studio 5.3.131.
I have this code that works fine inside of PowerShell ISE
get-WmiObject -class Win32_Share -ComputerName "machine1" | Select-Object Caption, path, name | ConvertTo-HTML | Out-File c:\Temp\shares.htm
Invoke-Expression C:\temp\shares.htm
it displays with 3 columns within Chrome.
Caption path name
Remote Admin C:\WINDOWS ADMIN$
Default share C:\ C$
Remote IPC IPC$
But when I put the same code within PowerShell Studio it displays way way more data. It displays all of this
PSComputerName Status Type Name __GENUS __CLASS __SUPERCLASS __DYNASTY __RELPATH __PROPERTY_COUNT __DERIVATION __SERVER __NAMESPACE
Why and how do I make it only display the 3 columns I need?
Thanks.
format and display in htm
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: format and display in htm
It works fine for me in PSS.
Try using this in a new PSQ file.
Try using this in a new PSQ file.
- get-WmiObject -class Win32_Share |
- Select-Object Caption, path, name |
- ConvertTo-HTML |
- Out-File c:\Temp\shares.htm
- Invoke-Expression C:\temp\shares.htm
Re: format and display in htm
OK, yours worked. But why? Do we not have basically the same code?
thank you.
thank you.
Re: format and display in htm
Go back and look at the actual code that is failing. Somewhere there is a mistake. I suspect the whole script may have some simple issue that is not obvious but now that you have a base proof you should be able to find the mistake. Sometimes pasting to copies of the same code and only editing the first copy will fool us into thinking we are running the fixed code. Step through the code with the debugger to verify that it is actually executing the code you think it is executing.
Re: format and display in htm
ok, this code works as expected.
if (Test-Path c:\Temp\shares.htm) {Remove-Item c:\Temp\shares.htm}
get-WmiObject -class Win32_Share -computername $pc |
Select-Object Caption, path, name |
ConvertTo-HTML |
Out-File c:\Temp\shares.htm
Invoke-Expression C:\temp\shares.htm
I have another question and I'm not sure if it is possible within PowerShell Studio. How would I change the colors in IE (or Chrome) when this code runs? When this code runs it has black font on a white background. I'd like to see black on a soft yellow. Or yellow on black. I've seen PowerShell scripts that format HTML output but is that possible within PowerShell Studio?
if (Test-Path c:\Temp\shares.htm) {Remove-Item c:\Temp\shares.htm}
get-WmiObject -class Win32_Share -computername $pc |
Select-Object Caption, path, name |
ConvertTo-HTML |
Out-File c:\Temp\shares.htm
Invoke-Expression C:\temp\shares.htm
I have another question and I'm not sure if it is possible within PowerShell Studio. How would I change the colors in IE (or Chrome) when this code runs? When this code runs it has black font on a white background. I'd like to see black on a soft yellow. Or yellow on black. I've seen PowerShell scripts that format HTML output but is that possible within PowerShell Studio?
Re: format and display in htm
help convertto-html -full does not say anything about color and from what I've Googled ConvertTo-HTML does not change the color. That seems to require more coding.
Thanks.
Thanks.