Skip to content

Instantly share code, notes, and snippets.

# Config
$Username = "Robert"
$Password = "rob"
$LocalFile = "C:\Temp\Test2.exe"
$RemoteFile = "ftp://ftphost/test.exe"
# Create a FTPWebRequest
$FTPRequest = [System.Net.FtpWebRequest]::Create($RemoteFile)
$FTPRequest.Credentials = New-Object System.Net.NetworkCredential($Username,$Password)
$FTPRequest.Method = [System.Net.WebRequestMethods+Ftp]::DownloadFile
@rob89m
rob89m / TimeSync.ps1
Last active December 23, 2019 01:12
Set Time Sync #NTP #TIME
<#
.DESCRIPTION
This script set external NTP to NTP.ORG then resync the time.
#>
# Set W32Time to Automatic start if not already enabled
Get-Service w32time | `
%{If($_.StartType -ne "Automatic"){Set-Service w32time -StartType Automatic}} | `
@rob89m
rob89m / AzureADSync.ps1
Last active December 13, 2019 00:25
SyncAzureAD #PowerShell #Azure #O365
<#
.DESCRIPTION
Simple script to run AzureADSync.
Compiling using PS2EXE-GUI (https://gallery.technet.microsoft.com/scriptcenter/PS2EXE-GUI-Convert-e7cb69d5) to an exe makes an easy tool to quickly trigger an Azure AD Sync.
.EXAMPLE
AzureADSync.ps1
#>
@rob89m
rob89m / Remove-ItemOnReboot.ps1
Last active November 29, 2021 09:30
Remove-ItemOnReboot #Powershell #Registry #Delete
<#
.DESCRIPTION
Adds defined item to the PendingFileRenameOperations value in Registry to be deleted on next reboot.
.EXAMPLE
If item to be removed is a file
Remove-ItemOnReboot -Item "C:\Temp\image.wim"
If item to be removed is a directory
Remove-ItemOnReboot -Item "C:\Temp\"