user3120098
user3120098

Reputation: 11

PowerShell - Remove text from output

I am running this command to find out when a license will expire on a set of servers:

cscript c:\Windows\System32\slmgr.vbs $server /xpr | Add-Content $LogFile

The output that is written to the LogFile looks like this:

Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

Windows Server(R), ServerStandard edition:
    Volume activation will expire 6/15/2014 1:12:33 PM

How can I remove the first three line in the output text file?

Upvotes: 1

Views: 793

Answers (2)

Rand0mAcc3ss
Rand0mAcc3ss

Reputation: 16

I would use //nologo. This option strips out the windows stuff and leaves you just the info you're looking for. If you still want a more precise output, try using regular expressions. Your ending command should look like this:

cscript //nologo c:\Windows\System32\slmgr.vbs $server /xpr | Add-Content $LogFile

Upvotes: 0

CIGuy
CIGuy

Reputation: 5114

Try adding the nologo directive.

cscript //nologo c:\Windows\System32\slmgr.vbs $server /xpr | Add-Content $LogFile

Upvotes: 3

Related Questions