Home > OS >  Powershell download/install fonts "deploy"
Powershell download/install fonts "deploy"

Time:05-20

I testing new powershell/batch download and install fonts oneliner, but with no luck so far (errors every time in cmd, under PS is OK)... I believe there is problem with quotes somewhere

point is simple oneliner runable from batch

POWERSHELL -NoProfile -ExecutionPolicy Bypass -Command "& {$fonts=@('Roboto','Ubuntu') | ForEach-Object {(New-Object System.Net.WebClient).DownloadFile('https://fonts.google.com/download?family=$_', '$env:TEMP\$_.zip'); Expand-Archive -Force '$env:TEMP\$_.zip' -DestinationPath '$env:TEMP\FONTS'}}"

thanks

CodePudding user response:

Since you are using single quotes in your command the variable substitution mechanism of Powershell will not work. So you have to use double quotes an mask them with a backslash. This worked for me:

POWERSHELL -NoProfile -ExecutionPolicy Bypass -Command "& {$fonts=@('Roboto','Ubuntu') | ForEach-Object {(New-Object System.Net.WebClient).DownloadFile(\"https://fonts.google.com/download?family=$_\", \"$env:TEMP\$_.zip\"); Expand-Archive -Force \"$env:TEMP\$_.zip\" -DestinationPath \"$env:TEMP\FONTS\"}}"
  • Related