d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Powershell Help
Add Reply New Topic New Poll
Member
Posts: 22,269
Joined: May 26 2007
Gold: 100.24
Feb 4 2013 04:03am
How do I silence certain parts of my script?

Let's assume I have code:


code here
New-Item ("c:\folder) -type directory
icacls "c:\folder" /grant:r "user `:(CI)(OI)F"
code here


I want to silence the output from those two lines. Currently the console tells me that

processed file: c:\folder
Successfully processed 1 files; Failed processing 0 files

Note that I need the output from lines before and after that part, so forwarding all output to void is not valid resolution in my case
Member
Posts: 2,579
Joined: Jun 1 2012
Gold: 1,524.00
Feb 4 2013 10:24am
Never used Powershell, but I googled Powershell comments and it appears you simply add a # at the beginning of the line.

For block comments, <# COMMENTED CODE #> should work.
Member
Posts: 22,269
Joined: May 26 2007
Gold: 100.24
Feb 15 2013 07:45am
Quote (Schwag @ 4 Feb 2013 18:24)
Never used Powershell, but I googled Powershell comments and it appears you simply add a # at the beginning of the line.

For block comments, <# COMMENTED CODE #> should work.


Thanks for the answer but I didn't mean commenting. I meant at the same style like

$ErrorActionPreference = "SilentlyContinue"

but so that it silences all output
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll