Skip to content

Instantly share code, notes, and snippets.

@bhavjot
Last active July 5, 2022 03:17
Show Gist options
  • Save bhavjot/6d29d5fc9514078a50867f1701454c9e to your computer and use it in GitHub Desktop.
Save bhavjot/6d29d5fc9514078a50867f1701454c9e to your computer and use it in GitHub Desktop.
#copying
Write-Host "Copying charts.."
Copy-Item "sorceaddress" -Destination "destaddress" -Recurse
$todayDate = Get-Date -UFormat "%Y%m%d"
#rename file
Rename-Item sourcefile.CSV newname.CSV
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = "exename"
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.Arguments = ""
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start() | Out-Null
#Do Other Stuff Here....
$p.WaitForExit()
$p.ExitCode
if ($p.ExitCode -ne 0) {
Write-Warning "$_ exited with status code $($p.ExitCode)"
}
#---------------------------------
# To kill Process
STOP-PROCESS
# To start a command
INVOKE-COMMAND
#Set Location - current working directory to specific location
SET-LOCATION
@bhavjot
Copy link
Author

bhavjot commented Mar 17, 2021

Run this command before running file
Set-Executionpolicy -Scope CurrentUser -ExecutionPolicy UnRestricted

At end
Set-Executionpolicy -Scope CurrentUser -ExecutionPolicy Restricted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment