Mark Minasi's Tech Forum
Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
tassinvegeta

Still Checking the Forum Out
Registered:
Posts: 6
Reply with quote  #1 

I have an issue where I'm trying to test the deployment of a powershell script via GPO through Windows Server 2012R2 Standard. This script is for the installation of MS Teams which is found here. https://gallery.technet.microsoft.com/scriptcenter/Install-Teams-using-ee647127#content 

 

However when putting it into the OU and loading it in Computer Configuration>Policies>Windows Settings>Scripts>Startup>Powershell Scripts the script only opens via notepad on the test Windows 10 machine without actually executing the powershell script.

 

Under script name I've tried various combinations of the absolute path. And tried different locations as to where to store the powershell script. Even when removing the GPO entirely the test machine still loads the notepad file and I can't seem to get rid of it. I've also tried the MSI but that doesn't seem to get deployed to the test machine at all. I've previously loaded the current adx templates for Windows 10 1909 so I'm kinda at a loss.

0
cj_berlin

Avatar / Picture

Senior Member
Registered:
Posts: 420
Reply with quote  #2 
Quote:
Originally Posted by tassinvegeta

However when putting it into the OU and loading it in Computer Configuration>Policies>Windows Settings>Scripts>Startup>Powershell Scripts the script only opens via notepad on the test Windows 10 machine without actually executing the powershell script.



Well, the obvious quick and dirty workaround would be calling a CMD wrapper as startup script which, in turn, would call 


powershell.exe -ExecutionPolicy Bypass -File "c:\path\to\script.ps1"


__________________
Evgenij Smirnov

My personal blog (German): http://www.it-pro-berlin.de/
My stuff on PSGallery: https://www.powershellgallery.com/profiles/it-pro-berlin.de/
0
jsclmedave

Administrator
Registered:
Posts: 501
Reply with quote  #3 
Quote:
Originally Posted by cj_berlin


Well, the obvious quick and dirty workaround would be calling a CMD wrapper as startup script which, in turn, would call 

 powershell.exe -ExecutionPolicy Bypass -File "c:\path\to\script.ps1" 



Agree  with CJ.  Quick is probebly the key thing here.

__________________
Tim Bolton @jsclmedave
Email: [string](0..20|%{[char][int](32+('527377347976847978324785847679797514357977').substring(($_*2),2))}) -replace ' '  

New to the forum? Please Read this
0
tassinvegeta

Still Checking the Forum Out
Registered:
Posts: 6
Reply with quote  #4 


Well this is how I added the scripts. Did I miss a step? The test machine still isn't installing the program though it sees the GPO via rsop.

The CMD Wrapper script is written as follows;
powershell.exe -ExecutionPolicy Bypass -File "\\servershare\MS Teams\Microsoft_Teams_x64bit.ps1"



tempsnidsddp.png    

0
cj_berlin

Avatar / Picture

Senior Member
Registered:
Posts: 420
Reply with quote  #5 
The CMD wrapper has to have the extension of .cmd and you need to put it in "Startup\Scripts", not in "Startup\PowerShell Scripts".
__________________
Evgenij Smirnov

My personal blog (German): http://www.it-pro-berlin.de/
My stuff on PSGallery: https://www.powershellgallery.com/profiles/it-pro-berlin.de/
0
tassinvegeta

Still Checking the Forum Out
Registered:
Posts: 6
Reply with quote  #6 
Thanks. There was a long startup and the install path was created. But the program didn't get installed for some reason. Wonder why the script works manually but now doesn't fully complete when run via GPO.

This is the contents of the script itself.

# Silently install Microsoft Teams with PowerShell Script.
# Download Microsoft Teams from https://teams.microsoft.com/downloads
# This script to install Microsoft Teams 64 bits if you want 32 bits you need to change on line 19, 20 & 27 to path of Teams 32 bits
# $source = "https://statics.teams.microsoft.com/production-windows-x64/1.1.00.29068/Teams_windows.exe"
# $destination = "$Installdir\Teams_windows.exe"
# Start-Process -FilePath "$Installdir\Teams_windows.exe" -ArgumentList "-s"

# Check if Software is installed already in registry.
$CheckTeamsReg = Get-ItemProperty HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | where {$_.DisplayName -like "Microsoft Teams*"}
# If Microsoft Teams is not installed continue with script. If it's istalled already script will exit.
If ($CheckTeamsReg -eq $null) {
$Installdir = "c:\Apps\install_Teams"    #path to download Microsoft Teams
New-Item -Path $Installdir -ItemType directory
# Download the installer from the Microsoft website. Check URL because it can be changed for new versions
$source = "https://teams.microsoft.com/downloads/desktopurl?env=production&plat=windows&arch=x64&download=true"
$destination = "$Installdir\Teams_windows_x64.exe"
Invoke-WebRequest $source -OutFile $destination
# Wait for the installation to finish. I've set it to 15 min. to take enough time until source of Microsoft Teams download from internet
Start-Sleep -s 120
# Start the installation of Microsoft Teams
Start-Process -FilePath "$Installdir\Teams_windows_x64.exe"
}



0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.