Skip to content

Instantly share code, notes, and snippets.

@KMR-zoar
Last active November 2, 2016 16:55
Show Gist options
  • Save KMR-zoar/edf6c5f3ed9b7afa3981 to your computer and use it in GitHub Desktop.
Save KMR-zoar/edf6c5f3ed9b7afa3981 to your computer and use it in GitHub Desktop.
$client = New-Object System.Net.WebClient
$url = "https://github.com/KMR-zoar/PowerShellPost/archive/master.zip"
Write-Host "Downloading PowerShellPost from Github."
$file = "$($env:TEMP)\PsPost.zip"
$client.DownloadFile($url,$file)
Write-Host "File saved to $file."
$ModulePath = "$($env:USERPROFILE)\Documents\WindowsPowerShell\Modules"
New-Item -Type Directory -Force -Path $ModulePath | Out-Null
$shell_app=new-object -com shell.application
$ZipFile = $shell_app.namespace($file)
Write-Host "UnZip file to $($ModulePath)."
$destination = $shell_app.namespace($ModulePath)
$destination.Copyhere($ZipFile.items(), 0x10)
Write-Host "Rename folder."
Rename-Item -Path ($ModulePath+"\PowerShellPost-master") -NewName "PsPost" -Force
$ModulePath = "$($env:USERPROFILE)\Documents\WindowsPowerShell\Modules\PsPost\lib\"
New-Item -Type Directory -Force -Path $ModulePath | Out-Null
Write-Host "Downloading NuGet.exe."
$url = "https://nuget.org/nuget.exe"
$file = "$($env:TEMP)\nuget.exe"
$client.DownloadFile($url,$file)
$runningDirectory = [string]$(Get-Location).Path
Set-Location $($env:TEMP)
Write-Host "Installing CoreTweet at Temporary Directory."
./nuget.exe install CoreTweet
Write-Host "Moving CoreTweet library to PowerShell Module Directory."
$CoreTweet = $(Get-ChildItem .\CoreTweet* | Sort-Object LastWriteTime | Select-Object -Last 1).name
$CoreTweet = "$($env:TEMP)\$CoreTweet\lib\net45\CoreTweet.dll"
Copy-Item $CoreTweet $ModulePath
$Newtonsoft = $(Get-ChildItem .\Newtonsoft* | Sort-Object LastWriteTime | Select-Object -Last 1).name
$Newtonsoft = "$($env:TEMP)\$Newtonsoft\lib\net45\Newtonsoft.Json.dll"
Copy-Item $Newtonsoft $ModulePath
Set-Location $runningDirectory
Start-Sleep -s 5
Write-Host "Module has been installed"
Import-Module -Name PsPost
Get-Command -Module PsPost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment