Install_Remote_Apps.ps1

<#PSScriptInfo
  
.VERSION 1.0.0
 
.GUID 46240b62-74f7-47b4-98a6-3a492945bbf5
  
.DESCRIPTION Install_Remote_Apps: Use this script to install Remote applications(EXE, MSI with silent instllation switches) from azure automation account, Please test before using it in production
  
.AUTHOR Amarnath Rajendran
  
.Company Tech Genius
  
.TAGS InstallApplication, Push Remote apps, Install remote msi
  
#>


param (
[Parameter(Mandatory=$true)]
[string] $Computer,
[Parameter(Mandatory=$true)]
[string] $SoftwareName,
[Parameter(Mandatory=$true)]
[string] $SharePath,
[Parameter(Mandatory=$true)]
[string] $filename
)


$Computer = Read-Host -Prompt 'Enter the Computer Name to install'
$SoftwareName = "winzip"
$filename = "winzip25.exe"


########## Install Software On PC ##########

New-Item -ItemType directory -Path "\\$Computer\c$\temp\$SoftwareName"

    Copy-Item "\\$Sharepath\$SoftwareName\$filename" "\\$Computer\c$\temp\$SoftwareName\$filename" -Recurse

    Write-Host "Installaing $SoftwareName on $Computer"

    Invoke-Command -ComputerName $Computer -ScriptBlock {Start-Process "c:\temp\$SoftwareName\$filename" -ArgumentList "/q" -Wait} 
    
########## Remove temporary files and folder on each PC ##########

    Write-Host "Removing Temporary files on $Computer"
    $RemovalPath = "\\$Computer\c$\temp\$SoftwareName"
    Get-ChildItem  -Path $RemovalPath -Recurse  | Remove-Item -Force -Recurse
    Remove-Item $RemovalPath -Force -Recurse