Answer the question
In order to leave comments, you need to log in
Downloading skype using PowerShell?
Task: make a policy that will install and update Skype for desktop.
I divided the task into 3 conditional subtasks:
1) Installation
2) Downloading new versions.
3) installing updates
1 and 3 the task can be solved using a batch file, here is its code
set VERSION=8.27.0.85
if %PROCESSOR_ARCHITECTURE% == x86 (
set FILENAME="C:\\Program Files\\Microsoft\\Skype for Desktop\\Skype.exe"
) else (
set FILENAME="C:\\Program Files (x86)\\Microsoft\\Skype for Desktop\\Skype.exe"
)
wmic datafile where name=%FILENAME% get version | find "%VERSION%"
if ERRORLEVEL 1 \\local.company.com\SHARES\PACKAGES\Skype-%VERSION%.exe /VERYSILENT /NORESTART
$Url = "https://go.skype.com/windows.desktop.download"
$Path = "D:\1.exe"
$WebClient = New-Object System.Net.WebClient
$WebClient.DownloadFile($url,$path)
Answer the question
In order to leave comments, you need to log in
so you can see what version is on the server without downloading the file. Well, the name of the file. if microsoft changes it in the current setup, the code below will stop working.
$uri = " https://get.skype.com/go/getskype-skypeforwindows "
$request = Invoke-WebRequest -Uri $uri -method Get -MaximumRedirection 0 -ErrorAction SilentlyContinue
$skype_ver_on_server = ($request.headers.location - replace ".*/skype-|\.exe").Trim()
$skype_ver_on_server
thank you so much for your help!!!
if anyone needs it, I post the final version of the script !!
$PatchScrpts ="D:\SkypeInstal\Final"
# Get the latest version of SKYPE from the server
$uri = " https://get.skype.com/go/getskype-skypeforwindows "
$request = Invoke-WebRequest -Uri $uri -method Get -MaximumRedirection 0 -ErrorAction SilentlyContinue
$skype_ver_on_server = $request.Headers.Location
# Parse get string extract version !!
$skype_ver_on_server =$skype_ver_on_server -replace ".*/Skype-",""
$skype_ver_on_server =$skype_ver_on_server -replace ".exe",""
$skype_ver_on_local = Get-Content $PatchScrpts\localver.txt
# Check local and received versions IF NOT EQUAL download, change version in 2 places....
if ( $skype_ver_on_local -ne $skype_ver_on_server )
{
# Download new
$Url = " https://go.skype.com/windows.desktop.download "
$Path = $PatchScrpts + "\Skype-"+ $skype_ver_on_server + ".exe"
$WebClient = New-Object System.Net.WebClient
$WebClient. DownloadFile($url,$path)
# Change to txt
$skype_ver_on_server | Out-File $PatchScrpts\localver.txt
# Change in batch file
$FileName = $PatchScrpts+"\SkypeInst.Bat"
[String]$string = "set VERSION="+$skype_ver_on_server
Foreach ($Line in $FileOriginal){
if ($Line.StartsWith("set VERSION="))
{
$FileModified += $Line.Replace($Line, $string)
} else {
$FileModified += $Line
}
}
Set-Content $fileName $FileModified -Force
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question