Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

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?

 

Capture.PNG

 

Thanks :)

Posted

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.

  • Thanks 1
  • 2 weeks later...
Posted (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 by FN-GM

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...