Home
Microsoft 365
Linux
Windows
Powershell
Cloud Computing
    Citrix Xendesktop
    Citrix XenApp
Useful links
About
  • Home
  • Microsoft 365
  • Linux
  • Windows
  • Powershell
  • Cloud Computing
    • Citrix Xendesktop
    • Citrix XenApp
  • Useful links
  • About
ajni.IT -
Azure•Cloud Computing•Powershell•Virtualization

Start an Azure VM with Azure Automation Webhooks

February 12, 2025 by AJNI No Comments

If you need a quick and dirty way to give a user the permission to start a VM without giving them access to the Azure Portal, Azure Automation Webhooks might help. You basically create a PowerShell script that starts the VM and then you configure the Webhook. The Webhook contains an URL which triggers the exceution of that script. Note that everyone with the URI is able to start the VM, which is not optimal.

Once you have created the Automation Account (easy), configure a new Runbook that starts the VM:

Disable-AzContextAutosave -Scope Process

$subscriptionID = Get-AutomationVariable -Name 'SubscriptionID'

Connect-AzAccount -Identity

Select-AzSubscription $SubscriptionId

Start-AzVM -ResourceGroupName "rgname" -name "vmname"

Configure the WebHook. You will get an URI. Save that URI somewhere, since you cannot view it after being created.

Afterwards, a user can run this line to start the VM:

Invoke-WebRequest -URI "https://xxxx.webhook.webhook.azure-automation.net/XXX" -Method POST -UseBasicParsing

Note: the automation account needs to have Virtual Machine Contributor rights on the resource group or subscription to start the VM.

References:

https://learnwithlenny.azurewebsites.net/2022/11/04/starting-an-azure-vm-using-webhook-powershell-exe/

Reading time: 1 min
Powershell•Windows Client OS•Windows Server

Uninstall Windows Program through PowerShell

December 4, 2024 by AJNI No Comments

Here are 2 quick lines of code that help you uninstall a Program:

$Prog = Get-WmiObject -Class Win32_Product | Where-Object{$_.Name -match “ProgramName”}
$Prog.Uninstall()

Reading time: 1 min
Powershell•Windows Client OS•Windows Server

Deploy MS Store App with Powershell – Windows 10/11

November 24, 2024 by AJNI No Comments

If you need to deploy a MS Store App for example through Intune or GPO, here is my script:

First of all you need the App ID of the store app. Go to https://apps.microsoft.com/ search for the app and select it. In the URL you will see something like this: https://apps.microsoft.com/detail/9nw77489ngj0?hl=en-us&gl=US. 9nw77489ngj0 is the App ID.

Now the script:

Start-Transcript -Path “C:\3cx_msstore.log”

$appid=”9NW77489NGJ0″

winget install -e –id $appid –source msstore –accept-source-agreements –accept-package-agreements

winget upgrade –id $appid

Stop-Transcript

Reading time: 1 min
Powershell•Windows Server

Check NTFS inheritance on Windows Fileserver with PowerShell

June 11, 2024 by AJNI No Comments

This quick script shows you if and where inheritance is deactivated. You can also set in the parameters how deep or how many levels inheritance is checked.

# Function to check inheritance up to the specified level
function Check-Inheritance {
    param (
        [string]$directoryPath,
        [int]$currentLevel,
        [int]$maxLevel
    )

    # Exit if current level exceeds max level
    if ($currentLevel -gt $maxLevel) {
        return
    }

    # Get the ACL of the directory
    $acl = Get-Acl -Path $directoryPath

    # Check if inheritance is disabled
    if ($acl.AreAccessRulesProtected) {
        Write-Output "$directoryPath - Inheritance is disabled"
    } else {
        #Write-Output "$directoryPath - Inheritance is enabled"
    }

    # Recursively check subdirectories if current level is less than max level
    if ($currentLevel -lt $maxLevel) {
        $subdirectories = Get-ChildItem -Path $directoryPath -Directory
        foreach ($subdir in $subdirectories) {
            Check-Inheritance -directoryPath $subdir.FullName -currentLevel ($currentLevel + 1) -maxLevel $maxLevel
        }
    }
}
# Function to check inheritance up to the specified level
function Check-Inheritance {
    param (
        [string]$directoryPath,
        [int]$currentLevel,
        [int]$maxLevel
    )

    # Exit if current level exceeds max level
    if ($currentLevel -gt $maxLevel) {
        return
    }

    # Get the ACL of the directory
    $acl = Get-Acl -Path $directoryPath

    # Check if inheritance is disabled
    if ($acl.AreAccessRulesProtected) {
        Write-Output "$directoryPath - Inheritance is disabled"
    } else {
        #Write-Output "$directoryPath - Inheritance is enabled"
    }

    # Recursively check subdirectories if current level is less than max level
    if ($currentLevel -lt $maxLevel) {
        $subdirectories = Get-ChildItem -Path $directoryPath -Directory
        foreach ($subdir in $subdirectories) {
            Check-Inheritance -directoryPath $subdir.FullName -currentLevel ($currentLevel + 1) -maxLevel $maxLevel
        }
    }
}

To execute the script:

Check-Inheritance -directoryPath $rootDirectory -currentLevel 1 -maxLevel 3 
Reading time: 1 min
Powershell•Windows Client OS•Windows Server

Run program with arguments with PowerShell

May 17, 2024 by AJNI No Comments

A follow-up on the last post here is another way to run msiexec through PowerShell.

For example, here is how you can install OCS inventory agent with some parameters. OCS is an open source inventarization system.

Start-Process -FilePath .\OCS-Windows-Agent-Setup-x64.exe -ArgumentList ‘/S /NOSPLASH /NOW /SERVER=https://inventory.ajni.it//ocsinventory /TAG=”a” /SSL=0’

References:

https://www.ajni.it/2024/04/run-msiexec-transforms-with-powershell/

Reading time: 1 min
Page 1 of 51234»...Last »

Like what you are reading? Buy me a coffee.

Tip Of the Day

  • Add Alias to Windows Fileserver (Server 2019, 2022, 2025)

    1 month ago

Keep in touch

Oh hi there!
It’s nice to meet you.

Sign up to receive awesome content in your inbox, every month.

Check your inbox or spam folder to confirm your subscription.

Categories

  • AI & Deep Learning (1)
  • Azure (20)
  • Citrix XenApp (21)
  • Citrix Xendesktop (13)
  • Cloud Computing (40)
  • Coding (1)
  • Hyper-V (10)
  • Linux (8)
  • Microsoft 365 (26)
  • Powershell (21)
  • Security (7)
  • VDI (16)
  • Virtualization (21)
  • VMware (12)
  • Windows (21)
  • Windows Client OS (39)
  • Windows Server (92)

Archives

  • May 2025
  • April 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • April 2023
  • March 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • December 2020
  • November 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019

ajni IT © 2019