Quote from DaviddeArgentina on October 13, 2021, 4:15 pmHi overthere,
There are a lot of new services based on the PowerShell enviroment.
I recreated a simple sample in order to show how to integrate PowerShell with NBW.
This sample was tested on Win7 and newer
First step: create a .PS1 file.
PS1 is the extension used by PowerShell in order to execute the scripts.
This sample was created based on the Function Library of NVW, to execute a FTP commands.
The NBW function script is:
FileWrite "[TmpDir]\ftp.ps1" "All" "$source = [#34][FileName][#34]" FileWrite "[TmpDir]\ftp.ps1" "Append" "$target = [#34]ftp://yourFTPserver.com/yourFolder/File_[date24]_[time].jpg[#34]" FileWrite "[TmpDir]\ftp.ps1" "Append" "$client = New-Object System.Net.WebClient" FileWrite "[TmpDir]\ftp.ps1" "Append" "$client.Credentials = New-Object System.Net.NetworkCredential([#34]YourFTPAccount[#34], [#34]yourFTPPass[#34])" FileWrite "[TmpDir]\ftp.ps1" "Append" "$client.UploadFile($target, $source)"Obviously, you must change or define the Source, Target, Server, User and Pass variables.
Second Step: Create a .BAT file
In order to send the correct syntax to PowerShell
The sample is:
FileWrite "!c:\MyFolder\send.bat" "All" "powershell -ExecutionPolicy Unrestricted -File c:\MyFolder\ftp.ps1"
Third step: run the .BAT program
Run "!c:\MyFolder\send.bat" "" "Hidden" "" ""This scripts do the job.
In the practice, copy all actions into a new function library with this lines:
FileWrite "[TmpDir]\ftp.ps1" "All" "$source = [#34][FileName][#34]"
FileWrite "[TmpDir]\ftp.ps1" "Append" "$target = [#34]ftp://yourFTPserver.com/yourFolder/File_[date24]_[time].jpg[#34]"
FileWrite "[TmpDir]\ftp.ps1" "Append" "$client = New-Object System.Net.WebClient"
FileWrite "[TmpDir]\ftp.ps1" "Append" "$client.Credentials = New-Object System.Net.NetworkCredential([#34]YourFTPAccount[#34], [#34]yourFTPPass[#34])"
FileWrite "[TmpDir]\ftp.ps1" "Append" "$client.UploadFile($target, $source)"FileWrite "!c:\MyFolder\send.bat" "All" "powershell -ExecutionPolicy Unrestricted -File c:\MyFolder\ftp.ps1"
Run "!c:\misfotos\send.bat" "" "Hidden" "" ""
Then, recreate the variables you use with your own idea, and addapt this sample for your use.
Greetings from Buenos Aires,
David de Argentina
Hi overthere,
There are a lot of new services based on the PowerShell enviroment.
I recreated a simple sample in order to show how to integrate PowerShell with NBW.
This sample was tested on Win7 and newer
First step: create a .PS1 file.
PS1 is the extension used by PowerShell in order to execute the scripts.
This sample was created based on the Function Library of NVW, to execute a FTP commands.
The NBW function script is:
FileWrite "[TmpDir]\ftp.ps1" "All" "$source = [#34][FileName][#34]" FileWrite "[TmpDir]\ftp.ps1" "Append" "$target = [#34]ftp://yourFTPserver.com/yourFolder/File_[date24]_[time].jpg[#34]" FileWrite "[TmpDir]\ftp.ps1" "Append" "$client = New-Object System.Net.WebClient" FileWrite "[TmpDir]\ftp.ps1" "Append" "$client.Credentials = New-Object System.Net.NetworkCredential([#34]YourFTPAccount[#34], [#34]yourFTPPass[#34])" FileWrite "[TmpDir]\ftp.ps1" "Append" "$client.UploadFile($target, $source)"
Obviously, you must change or define the Source, Target, Server, User and Pass variables.
Second Step: Create a .BAT file
In order to send the correct syntax to PowerShell
The sample is:
FileWrite "!c:\MyFolder\send.bat" "All" "powershell -ExecutionPolicy Unrestricted -File c:\MyFolder\ftp.ps1"
Third step: run the .BAT program
Run "!c:\MyFolder\send.bat" "" "Hidden" "" ""
This scripts do the job.
In the practice, copy all actions into a new function library with this lines:
FileWrite "[TmpDir]\ftp.ps1" "All" "$source = [#34][FileName][#34]"
FileWrite "[TmpDir]\ftp.ps1" "Append" "$target = [#34]ftp://yourFTPserver.com/yourFolder/File_[date24]_[time].jpg[#34]"
FileWrite "[TmpDir]\ftp.ps1" "Append" "$client = New-Object System.Net.WebClient"
FileWrite "[TmpDir]\ftp.ps1" "Append" "$client.Credentials = New-Object System.Net.NetworkCredential([#34]YourFTPAccount[#34], [#34]yourFTPPass[#34])"
FileWrite "[TmpDir]\ftp.ps1" "Append" "$client.UploadFile($target, $source)"
FileWrite "!c:\MyFolder\send.bat" "All" "powershell -ExecutionPolicy Unrestricted -File c:\MyFolder\ftp.ps1"
Run "!c:\misfotos\send.bat" "" "Hidden" "" ""
Then, recreate the variables you use with your own idea, and addapt this sample for your use.
Greetings from Buenos Aires,
David de Argentina
Quote from DaviddeArgentina on October 13, 2021, 4:25 pmUpssss...
change this line:
FileWrite "!c:\MyFolder\send.bat" "All" "powershell -ExecutionPolicy Unrestricted -File c:\MyFolder\ftp.ps1"to this one:FileWrite "!c:\MyFolder\send.bat" "All" "powershell -ExecutionPolicy Unrestricted -File [TmpDir]\ftp.ps1":-)
Upssss...
change this line:
Quote from emo on October 14, 2021, 12:41 pmHello @daviddeargentina , very interesting your contribution. I leave you a repository of scripts in Powershell that you can surely take advantage of ;-)
https://github.com/fleschutz/PowerShell
Greetings
Hello @daviddeargentina , very interesting your contribution. I leave you a repository of scripts in Powershell that you can surely take advantage of ;-)
https://github.com/fleschutz/PowerShell
Greetings
Quote from DaviddeArgentina on October 14, 2021, 4:48 pm@emmanuel-fernandez
WOW !!!
Thanks a bunch !
WOW !!!
Thanks a bunch !