Wind32 App (Powershell Script) intune deployment - intune

If i run this locally on the machine after getting to the correct directory, the uninstall / install works great. But it's after I convert to intunewin file and upload to intune that i keep getting failed to install error.
Have the .msi as the "setup file" for intunewin. I originally had the .ps1 as set up, but that didn't work. I also verified i'm running it using the system account when deploying through intune.
$software = Get-Package -Name "TeamViewer 12 Host (MSI Wrapper)"
if ($software.Name -eq "TeamViewer 12 Host (MSI Wrapper)") {
Uninstall-Package -Name "TeamViewer 12 Host (MSI Wrapper)" -Force
}else{
Write-Host "Uninstalled"
}
Start-Process msiexec.exe -ArgumentList '/i TeamViewer_Host.msi /qn CUSTOMCONFIGID=xxxxxx APITOKEN=xxxxxxxxxx ASSIGNMENTOPTIONS="--grant-easy-access --reassign"'

Related

MSIX in Docker container

Does anyone know how to install an MSIX package into a Docker container?
Currently my Dockerfile does the following:
Install PFX certificate to "Trusted Root Certification Authorities", which is specified by "Cert:\LocalMachine\Root" in the PowerShell command.
Copy MSIX package from network drive.
Install MSIX as an app. (Fails)
Remove local copy of MSIX package.
Dockerfile:
RUN powershell $pwd = ConvertTo-SecureString -String 'CeRtPaSsWoRd' -AsPlainText -Force; Import-PfxCertificate -Password $pwd -FilePath "R:/app-stream-cert.pfx" -CertStoreLocation Cert:\LocalMachine\Root \
&& copy "R:/mcre-22-r2-x64.msix" "C:/" \
&& powershell Add-AppPackage -path "C:/mcre-22-r2-x64.msix" \
&& del "C:/mcre-22-r2-x64.msix"
I have this error:
Add-AppPackage : Deployment failed with HRESULT: 0x80073D19, An error occurred
because a user was logged off.
error 0x80073D0A: Failed to install package
AnsysInc.mcre-22-r2_22.2.0.0_x64__13gfg92hgbc9g because the firewall service
is not running. Ensure that the firewall service is enabled and started.
NOTE: For additional information, look for [ActivityId]
b9bbd738-fed5-0000-fec9-bdb9d5fed801 in the Event Log or use the command line
Get-AppPackageLog -ActivityID b9bbd738-fed5-0000-fec9-bdb9d5fed801
At line:1 char:1
+ Add-AppPackage -path C:/mcre-22-r2-x64.msix
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (C:\mcre-22-r2-x64.msix:String) [A
dd-AppxPackage], Exception
+ FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageMa
nager.Commands.AddAppxPackageCommand
I've tried enabling firewall service in the container and on the host machine using powershell Start-Service -Name mpssvc. I'm able to enable firewall service on the host, but not in the container. Some posts indicate that Windows Docker containers share firewall service with their host. However my 0x80073D0A error still persists.
Environment info:
Docker engine version 20.10.21
Base image mcr.microsoft.com/windows:20H2
Host OS Win 10 Pro 10.0.19044.2251

Install RSAT using powershell script to windows 10 with elevated privileges

I am facing a difficulty on installing RSAT to remote windows 10 workstations via gpo. My main goal is to use Get-ADuser command as a necessity to gain information from my Windows domain.
I created a PowerShell script using the following command:
Get-WindowsCapability -Name RSAT* -Online | Add-WindowsCapability –Online
Yet when I run it, a message appears asking for elevated privileges.
So I tried to add credentials in order to automate the installation and changed the script to :
$Username = 'domain\domain_adm'
$Password = '*******'
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
Start-Process -FilePath powershell.exe -ArgumentList{Get-WindowsCapability -Name RSAT* -Online | Add-WindowsCapability –Online} -credential $Cred
And from a normal PowerShell window, it works. But, it doesn't when I am trying to use it from gpo.
Could you please assist me?
The goal is to install via GPO Get-ADuser (maybe RSAT) to domain workstations with OS Windows 10
For a small number of machines Powershell is not a bad option. If you have access to GPOs then you should use then. RSAT is "Windows feature". You can use WSUS. https://4sysops.com/archives/install-rsat-1809-and-other-optional-features-in-wsus-environments/ You could also use the software that you use to install software on the machine on the network . Many of software distribution packages run as root when it installs software. In this case just give that team the line below.
Get-WindowsCapability -Name RSAT* -Online | Add-WindowsCapability –Online
Why are you putting credentials in clear text in a script file? That
is just bad practice and should not be done.
Installing software is an Admin level thing, local, GPO, or
otherwise, because it's a system-wide change.
Lastly, this is not a PowerShell code/programming issue and not something PowerShell can fix relative to how you are trying to do this. It's specifically how do I use GPO to enable a Windows feature or install software, using PowerShell?
So, could be considered off-topic for Stackoverflow and more a question for SuperUser or StackExchange.
All that being said, you can still use PowerShell to do this, but doing so by using PowerShell to set a scheduled task to the targets and set that to the admin creds at run once at login.
You can write a separate script to create the scheduled task.
You can use the below script for the RSAT install effort via the task.
Use PowerShell to Create Scheduled Tasks
New-ScheduledTask
Very similar to this approach with updating PowerShell help:
PowerShell: Update-Help via Scheduled Task in Group Policy Preferences
As far as what js2010 has stated. That was true for earlier versions of Windows 10. The current state of things is as noted below.
Install RSAT for Windows 10 1809 and 1903 and 1909 automated
RSAT (Remote Server Administration Tools) in Windows 10 v1809 and
v1903 are no longer a downloadable add-on to Windows. Instead, its
included as a set of "Features on Demand" directly in Windows.
Download: Install-RSATv1809v1903v1909.ps1
Long term Scheduled Task management can be accomplished via GPO as well, as noted here:
Managing Scheduled Tasks from Group Policy
You can download RSAT as an msu file: https://www.microsoft.com/en-us/download/details.aspx?id=45520
EDIT: Ok, as for 1809 and above, my first thoughts are a gpo startup script, or using invoke-command.

Installing a software remotely on windows is failing. But, when logged into the machine, everything works fine

I'm trying to install SQL Express on Windows 2012R2 server remotely either using "windows_package/powershell_script" chef resources. I tried executing the script I have after remoting into the machine, it installs fine.
But, when I try to execute it remotely using Chef/Powershell, it's neither installing the software nor giving out an error. Is this because of configuration issues?
Currently when I attempt to use the below resources, nothing is installing:
1. Windows_package:
windows_package 'Install SQL Express' do
source 'C:\\Folder\\SQLEXPR_x64_ENU.exe'
action :install
options '/QUIET /SAPWD="C0mp!ex" /ConfigurationFile="C:\\Folder\\sql_express.ini" /TCPENABLED="1" /SECURITYMODE="SQL"'
end
2. powershell_script:
powershell_script 'Install SQL Express' do
code <<-EOH
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted -Force
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted -Force
Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy Unrestricted -Force
C:\\Folder\\sql_express.ps1
EOH
end
And the Powershell script that I used is:
$app = 'C:\\Folder\\SQLEXPR_x64_ENU.exe'
$myarg = '/QUIET /SAPWD="C0mp!ex" /ConfigurationFile="C:\\Folder\\sql_express.ini" /TCPENABLED="1" /SECURITYMODE="SQL"'
Start-Process $app -ArgumentList $myarg
Start-Sleep 300
The Powershell script when ran on the machine, it works fine. Why is the script working fine when executed on the machine and not remotely?
Please let me know if I need to make any changes to the script or resources to make it work.
Thanks in advance.

Windows Server 2016 Docker image support for SQL Server?

I've taken note of various Dockerfiles for SQL Server support, most recently: https://blogs.msdn.microsoft.com/sqlserverstorageengine/2016/03/21/sql-server-in-windows-containers/
And, I've seen the SQL Server Image support provided by WinDocks on Windows Server 2012 but I haven't seen whether Microsoft has announced plans to support SQL Server 2016 with Docker image support on Windows Server 2016? And, if so, has anyone heard if MS plans to include support in dockerfile support for adding or mounting databases in containers? Thanks in advance!
UPDATE: The SQL Server team now maintains a 2014 Express image on Docker Hub: https://hub.docker.com/r/microsoft/mssql-server-2014-express-windows/
SQL Server 2016 is currently a little harder to install, but 2014 works fine. Here's my (slightly hacky) Dockerfile:
FROM microsoft/dotnet35
ENV SQL_EXPRESS_DOWNLOAD_URL "https://download.microsoft.com/download/1/5/6/156992E6-F7C7-4E55-833D-249BD2348138/ENU/x64/SQLEXPR_x64_ENU.exe"
ENV SQL_SERVER_SA_PASSWORD "Password1"
WORKDIR /
RUN powershell -Command (New-Object System.Net.WebClient).DownloadFile('%SQL_EXPRESS_DOWNLOAD_URL%', 'sqlexpress.exe')
RUN /sqlexpress.exe /qs /x:setup && /setup/setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SECURITYMODE=SQL /SAPWD=%SQL_SERVER_SA_PASSWORD% /SQLSVCACCOUNT="NT AUTHORITY\System" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS && del /F /Q sqlexpress.exe && rd /q /s setup
RUN powershell -Command \
set-strictmode -version latest ; \
stop-service MSSQL`$SQLEXPRESS ; \
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql12.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql12.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \
start-service MSSQL`$SQLEXPRESS
CMD powershell -Command while ($true) { Start-Sleep -Seconds 3600 }
EXPOSE 1433
It's based on this one: https://github.com/brogersyh/Dockerfiles-for-windows/blob/master/sqlexpress/dockerfile
Follow up on this, Microsoft released Windows Server core 1709 with support for network attached SMB shares. I also note that Windocks has released Docker SQL Server container database cloning support, which I've tested using Core 1709,and can now service a team with 500 GB data images in roughly 1 minute. You can see more on Windocks at https://windocks.com/docker-sql-server-containers
If you want to install a full version of sql server (not only the Express version), here's how you can do it: https://github.com/mabead/Docker.SqlServer

How to execute a PostGre exe file with silent mode?

Hy,
I would install PostGreSQL 9.1 on a Windows Server 2012.
I want to used a PowerShell script.
With my JDK executables file, I use Start-Process "Myfile" -ArgumentList "/s" -Wait
But the argument \s don't work with my PostGre executables file.
Have you an idea ?
You can use Install-Postgres Powershell module, it's on TechNet Gallery.
The Install-PostgreSQL PowerShell module does the following:
creates a local windows user that PostgreSQL will use
downloads the PostgreSQL installer provided by EnterpriseDB
installs Postgres unattended using the supplied parameters
sets postgres windows user as owner of Postgres files and folders
sets Postgres windows service to run under postgres local user
creates pgpass.conf file in AppData
copies configuration files to data directory
opens the supplied port that PostgreSQL will use in the Windows
Firewall
Usage
Import-Module Install-Postgres
Install-Postgres -User "postgres" -Password "ChangeMe!"
I have used this command : Start-Process $installFile -ArgumentList "--unattendedmodeui minimal --mode unattended --prefix $dest --datadir $dest\data --servicepassword $pwd" -Wait
Thanks for your help ! :)

Resources