FN-GM Posted March 4, 2012 Posted March 4, 2012 Hi, I have put together my own powershell script that will disable computers.I would like to create a log file of what computers are actually disabled. | Out-File -append C:\log.txt The above puts a list of computers disabled into a text file. I would like it so it puts a date the command was actioned next to the computer name. Also it puts headings above the computer names like the below. Does anyone know if its possible so it doesn't keep putting duplicating the heading please? Thanks
ascott2 Posted March 12, 2012 Posted March 12, 2012 Use the -HideTableHeaders switch on the format-table command to hide those headers. To add the current time to the table you will need to customize your table layout. For example | Format-Table Name, Type, DN, @{Expression={Get-Date};Label="Time"} | out-file log.txt Have not tested but should get you going. 1
FN-GM Posted March 21, 2012 Author Posted March 21, 2012 (edited) Thanks for the tips @ascott2 - Just 2 questions. How do i stop it from clipping the DN. I think i need to adjust the width of the column. Also how would i prevent it from putting in those 3 blank lines under the log in the txt file please? Thanks Edited March 21, 2012 by FN-GM
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now