Forum Discussion
CS_HelpDesk
3 years agoGoTo Contributor
Remote Execution - PowerShell Script Repository
Welcome to the Remote Execution - Powershell Script Repository!
What is it? A library of scripts to help you execute automated tasks and manage your Central computers without having to access them manually.
How does it work? Simply browse the replies below, copy and paste to the Remote Execution job screen in your Central console.
How can you help? We encourage you to share your own scripts and/or help review the scripts of others-- just "Kudo" your favorites or reply with your comments.
Use of these scripts is at your own risk so please test them on a small number of systems before deploying at scale. The scripts are provided “as is” without any warranty of any kind and GoTo , Inc disclaims any and all liability regarding any use of the scripts. Please see the following Terms and Conditions for more information.
Remember: The currently running Remote Execution script ends when either the host service stops or the script includes computer shutdown or reboot tasks.
- Shutdown Script
- Executable file run script
- File Distribution script
- File Copy
- File Move
- File Delete
- Folder Creation
- Folder Copy
- Folder Move
- Folder Delete
- Compress to zip
- Extract from Zip
- Display a message box
- MSI installation
- MSI Uninstall
- Winget Install
- Microsoft Defender- Quick Scan
- Microsoft Defender - Full Scan
- Microsoft Defender - Custom Scan
- Microsoft Defender update
- Service - Start
- Service - Stop
- Service - Restart
- Registry Import
- Clear DNS cache
27 Replies
Replies have been turned off for this discussion
- CS_HelpDesk3 years agoGoTo Contributor
To delete a file.
---
$filePath = $null
if (Test-Path -Path $filePath -PathType Leaf)
{
Remove-Item $filePath -Force
}
else
{
Write-error -Message "$filePath doesn't exist" -Category InvalidArgument
}
- CS_HelpDesk3 years agoGoTo Contributor
Move a file to a destination.
---
$source = $null
$destination = $null
$overwrite = $false
If (-Not (Test-Path -Path $destination -PathType Container))
{
New-Item -Path $destination -ItemType Container
}
Move-Item $source -Destination $destination -Force:$overwrite –Verbose
- CS_HelpDesk3 years agoGoTo Contributor
Copy a file to a destination.
---
$source = $null
$destination = $null
$overwrite = $false
If (-Not (Test-Path -Path $destination -PathType Container))
{
New-Item -Path $destination -ItemType Directory
}
$exclude = If($overwrite) { {} } else { Get-ChildItem $destination }
Copy-Item $source -Destination $destination -Exclude $exclude.FullName -Force:$overwrite –Verbose
- CS_HelpDesk3 years agoGoTo Contributor
Downloads file from a given URL to the working directory or to a specified folder.
$url = $null
$destination = 'C:\DistributedFiles'
$fileName = $null
$outFile = $fileName;
if (-Not $outFile)
{
$outFile = $url.Split('/')[-1];
$outFile = $outFile.Split('?')[0];
}
If (-Not (Test-Path -Path $destination -PathType Container))
{
New-Item -Path $destination -ItemType Container
}
$outPath = Join-Path -Path $destination -ChildPath $outFile
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($url, $outPath)
- CS_HelpDesk3 years agoGoTo Contributor
Upload files and set their destination.
File location is an example.
--
$destination = 'C:\DistributedFiles'
$overwrite = $false
If (-Not (Test-Path -Path $destination -PathType Container))
{
New-Item -Path $destination -ItemType Container
}
$resolve_Files | % { Move-Item -Path $_ -Destination $destination -Force:$overwrite }
- CS_HelpDesk3 years agoGoTo Contributor
Upload an .EXE file. You must set the file to run silently and without user input.
$arguments = $null
$file = $resolve_Files[0];
if ($arguments)
{
$process = Start-Process $file -Args $arguments -Wait -NoNewWindow -PassThru;
}
else
{
$process = Start-Process $file -Wait -NoNewWindow -PassThru;
}
Exit $process.ExitCode
- CS_HelpDesk3 years agoGoTo Contributor
Stop-Computer –force