Article From:https://www.cnblogs.com/quinn-yann/p/9688734.html

Powershell is installed in window systems in default.

run in ‘cmd’

powershell -command xxx.ps1

 

Solution: running this command before the script also solves the issue:

set-executionpolicy unrestricted

 

 

Solution: execute “cmd” by administrator or run in “window powershell”

 

 

Run “powershell -command xxx.ps1”

 

Solution:

run “powershell -command .\xxx.ps1″

 

 Success!.

 

Note:

Please, filenames or folders do not start with number like this, it will cannot be executed by powershell.

foreach($f in gci VPN-NonVPN-20180629 *.pcap)
{
    0_Tool\SplitCap_2-1\SplitCap -p 100000 -b 100000 -r $f.FullName -o 2_Session\AllLayers\$($f.BaseName)-ALL
    # 0_Tool\SplitCap_2-1\SplitCap -p 100000 -b 100000 -r $f.FullName -s flow -o 2_Session\AllLayers\$($f.BaseName)-ALL
    gci 2_Session\AllLayers\$($f.BaseName)-ALL | ?{$_.Length -eq 0} | del

    0_Tool\SplitCap_2-1\SplitCap -p 100000 -b 100000 -r $f.FullName -o 2_Session\L7\$($f.BaseName)-L7 -y L7
    # 0_Tool\SplitCap_2-1\SplitCap -p 100000 -b 100000 -r $f.FullName -s flow -o 2_Session\L7\$($f.BaseName)-L7 -y L7
    gci 2_Session\L7\$($f.BaseName)-L7 | ?{$_.Length -eq 0} | del
}

0_Tool\finddupe -del 2_Session\AllLayers
0_Tool\finddupe -del 2_Session\L7

 Solution: rename the filenames.

“0_Tool” -> “Tool”

 

Leave a Reply

Your email address will not be published. Required fields are marked *