Autopilot is an indispensable tool for managing and deploying Windows devices in the enterprise. Before deploying Autopilot, it is crucial to ensure that your environment meets the necessary prerequisites. This process can be time-consuming and prone to errors, which is why the Autopilot Prerequisite Checker has been introduced to automate the prerequisite checking process. The Autopilot Prerequisite Checker is a PowerShell script that validates whether your environment meets the requirements for deploying Autopilot. The updated script now checks for the following prerequisites: Tenant checks: Device checks: User checks: Network checks: Using the script is a breeze. It can be run … Continue reading
Category Archives: Powershell
Download all OneDrive files for a user using PowerShell
List Packages that run in user context (Run with user’s rights)
Introduction After last weeks post with the script sample to list Packages that run in user context, there where some good feedback from people still using packages, and requiring a list of packages that install within the user context (Run with user’s rights / Execution mode as user) It seemed that many was still using Packages, either as a result of legacy migration or to avoid some application re-packaging. So here is the followup post, with a new script to list all packages and package with programs that run in user context. From my point of view, its still the … Continue reading
List Applications that run in user context (Install for User)
Introduction When deploying applications sometimes they are created to install within the active users context. This means that the actual installation requires the users to have the needed permissions to the filesystem, registry and etc. In some cases local administrative rights are needed to perform the application installation, this is not a good practice. As applications mature for the modern design of the Windows Operating System or we choose to remove the users administrative rights due to security reasons, we may need to list and change the behavior of existing Applications. This script was created to list applications that is … Continue reading
Cleaning up shortcuts
So the issue at hand;I was replacing a Office application on Windows systems, where i noticed that shortcuts created by the users, was not upgraded/removed when the new office version was installed. The issue seems to be related to users creating custom shortcuts, directly to exe files.I some cases the shortcut name was clear, but in other cases the users had chosen something they found fit. The following PowerShell script was created to remove shortcuts (lnk files) based on the executable. This means you can specific the exe or use a wildcard if there is multiple executable files releated to … Continue reading
MSiX – Remote machine conversions
The MSiX Packaging Tool (1.2019.226.0) Preview now has the ability to connect to a remote machine, where you can run the conversion.This is great news, and solves the normal issue with contamination on “non-sanitised” machines. I have always preferred to do my packaging and re-packaging on Hyper-V Virtual Machines This gives a total control and clean enviroment, with easy ability to get back to a controlled point of reference, using checkpoints. Getting started with remote machine conversions? Fear not! It is quite simple to get started. – PowerShell remoting must be enabled for secure access to the remote machine.– You … Continue reading
Poweshell under the security context of another user (RunAs)
Recently i needed to run some powershell scripts under multiple security context’s – the main reason for this was my client’s strict delegation model. We ended up with multiple service account with rights only to the needed systems (Its not such a bad thing!) The result was this powershell script to change security context $SPAccountName = “<username>”; $AccountPassword = “<password>”; $AccountPasswordAsSecureString = $AccountPassword | ConvertTo-SecureString -Force -AsPlainText $credential = New-Object System.Management.Automation.PsCredential(“$env:userdomain\$SPAccountName”,$AccountPasswordAsSecureString) $SvcAccSession = New-PSSession -Credential $credential; Invoke-Command -Session $SvcAccSession -Script { Import-Module ActiveDirectory } Invoke-Command -Session $SvcAccSession -Script { Get-AdGroupMember “Some-group”} In the above example we just get the member of some … Continue reading
Unable to use Power Shell AD cmdlets on Remote Server
I came across this error when building a web service executing powershell cmdlets When executing the commands directly on the server worked without problems but when using New-PSSession to invoke the scripts I ended up with the following error: WARNING: Error initializing default drive: ‘Unable to contact the server. This may be because this server does not exist, it is currently down, or it does not have the Active Directory Web Services running.’. Unable to contact the server. This may be because this server does not exist, it is currently down, or it does not have the Active Directory Web … Continue reading
Change the size of a virtual machine by using a Azure PowerShell script
Finally i got around to moving my demo environment to Azure I don’t need my environment to perform 100% while not using it, so came a cross this nice way to scale my environment on-demand. This is possbile with a simple powershell script: Function HowTo-SetAzureVMSize{ [CmdletBinding()] param( [parameter(Mandatory=$true)] [string]$ServiceName, [parameter(Mandatory=$false)] [ValidateNotNullOrEmpty()] [string]$Name=$ServiceName, [parameter(Mandatory=$true)] [string]$VMSize ) PROCESS{ Get-AzureVM –ServiceName $ServiceName –Name $Name | Set-AzureVMSize $VMSize | Update-AzureVM } } HowTo-SetAzureVMSize -ServiceName {your-cloud-service-name} -Name {your-vm} –VMSize “{your-desired-vm-size}” Example: Function HowTo-SetAzureVMSize{ [CmdletBinding()] param( [parameter(Mandatory=$true)] [string]$ServiceName, [parameter(Mandatory=$false)] [ValidateNotNullOrEmpty()] [string]$Name=$ServiceName, [parameter(Mandatory=$true)] [string]$VMSize ) PROCESS{ Get-AzureVM –ServiceName $ServiceName –Name $Name | Set-AzureVMSize $VMSize | Update-AzureVM } … Continue reading
File cannot be loaded because the execution of scripts is disabled on this system
Error when trying to execute powershell script cannot be loaded because the execution of scripts is disabled on this system The machine was a x64 bit Windows Server 2012 so had to set the Powershell policy for BOTH x86 and x64 to solve my problem command: Set-ExecutionPolicy Unrestricted The x86 version can be found here: %windir%SysWOW64WindowsPowerShellv1.0 About Execution Policies: http://technet.microsoft.com/da-DK/library/hh847748.aspx Using the Set-ExecutionPolicy Cmdlet: http://technet.microsoft.com/en-us/library/ee176961.aspx