execute in command line

Hello,

I use this script:
https://gallery.technet.microsoft.com/scriptcenter/Run-defrag-on-local-or-b4a33bbb

I want execute in a command line but i don't find the solution, my powershell don't want the command in a .bat.

powershell "COMPUTER1","COMPUTER2" | .\Invoke-Defragmentation.ps1 -ForceDrives recommended

thx a lot,


September 9th, 2015 11:15am

powershell  -file c:\Invoke-Defragmentation.ps1 -ForceDrivesrecommended -Computer COMPUTER1
powershell  -file c:\Invoke-Defragmentation.ps1 -ForceDrivesrecommended -Computer COMPUTER2
Free Windows Admin Tool Kit Click here and download it now
September 9th, 2015 11:19am

Put everything you need to run the script into a .ps1 file and point at it with the -File parameter of powershel

September 9th, 2015 11:20am

OR -

powershell  -command { 'COMPUTER1','COMPUTER2' |%{$_|.\Invoke-Defragmentation.ps1 -ForceDrivesrecommended}

Free Windows Admin Tool Kit Click here and download it now
September 9th, 2015 11:29am

thx a lot
September 10th, 2015 3:51am

You're very welcome.
Free Windows Admin Tool Kit Click here and download it now
September 10th, 2015 9:27am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics