<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	 xmlns:media="http://search.yahoo.com/mrss/" >

<channel>
	<title>TechGuy</title>
	<atom:link href="https://www.techguy.at/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.techguy.at/</link>
	<description>Service Management, Automation, PowerShell, Azure Automation, Logic Apps, and more</description>
	<lastBuildDate>Fri, 29 Aug 2025 07:18:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.5</generator>

<image>
	<url>https://www.techguy.at/wp-content/uploads/2021/01/cropped-iPhone-32x32.png</url>
	<title>TechGuy</title>
	<link>https://www.techguy.at/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">12964289</site>	<item>
		<title>OneDrive offline Backup with PowerShell and GRAPH API</title>
		<link>https://www.techguy.at/onedrive-offline-backup-with-powershell-and-graph-api/</link>
					<comments>https://www.techguy.at/onedrive-offline-backup-with-powershell-and-graph-api/#respond</comments>
		
		<dc:creator><![CDATA[Michael Seidl]]></dc:creator>
		<pubDate>Fri, 29 Aug 2025 07:09:31 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<guid isPermaLink="false">https://www.techguy.at/?p=6288</guid>

					<description><![CDATA[<p>As a business owner, you will eventually have to deal with Backup and Security. So today, we are taking care of File Backup. All our files are backed up to OneDrive, so why do we need a Backup? All files are in the Cloud.Also, all Services we use are Cloud services, so why should we [&#8230;]</p>
<p>The post <a href="https://www.techguy.at/onedrive-offline-backup-with-powershell-and-graph-api/" data-wpel-link="internal">OneDrive offline Backup with PowerShell and GRAPH API</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->

Releated Posts:<ol>
<li><a href="https://www.techguy.at/send-a-onedrive-file-via-mail-with-ms-graph-api-and-powershell/" rel="bookmark" title="Send a OneDrive File via Mail with MS GRAPH API and Powershell" data-wpel-link="internal">Send a OneDrive File via Mail with MS GRAPH API and Powershell</a> <small>Recently, I automated our invoice sending and automatically uploaded the...</small></li>
<li><a href="https://www.techguy.at/upload-a-file-to-onedrive-via-graph-api-and-powershell/" rel="bookmark" title="Upload a File to OneDrive via Graph API and PowerShell" data-wpel-link="internal">Upload a File to OneDrive via Graph API and PowerShell</a> <small>Recently, I upgraded my Invoicing automation, so I create Invoices...</small></li>
<li><a href="https://www.techguy.at/use-microsoft-graph-api-with-powershell-part-2/" rel="bookmark" title="Use Microsoft Graph API with PowerShell – Part 2" data-wpel-link="internal">Use Microsoft Graph API with PowerShell – Part 2</a> <small>You read the second Part in this Series, where we...</small></li>
<li><a href="https://www.techguy.at/assign-a-user-to-an-azure-resource-group-role-with-powershell-and-ms-graph-api/" rel="bookmark" title="Assign a User to an Azure Resource Group Role with PowerShell and MS Graph API" data-wpel-link="internal">Assign a User to an Azure Resource Group Role with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
<li><a href="https://www.techguy.at/powershell-custom-install-module-function/" rel="bookmark" title="PowerShell custom Install Module Function" data-wpel-link="internal">PowerShell custom Install Module Function</a> <small>Usually, it is simple to run &#8220;Install-Module,&#8221; and the module...</small></li>
</ol>
</div>
]]></description>
										<content:encoded><![CDATA[
<p>As a business owner, you will eventually have to deal with Backup and Security. So today, we are taking care of File Backup.<br><br>All our files are backed up to OneDrive, so why do we need a Backup? All files are in the Cloud.<br>Also, all Services we use are Cloud services, so why should we back up anything?</p>



<p>Cause those Cloud Services might fail.<br>When we are honest, the Cloud is only someone else&#8217;s computer, so there can be an attack, an outage, or Data loss.<br>We can also experience some breaches, so the Cloud file gets encrypted. Now?</p>



<p>That is why I recently bought a UNIFI Storage for our offline Backup, and our first step was to save OneDrive to that Storage.</p>



<p>So, the easiest way would be to have a copy job on my computer, where OneDrive is located, and copy all the files to the Storage. But for this, I wouldn&#8217;t write a Blog Post; instead, I would download all the files to your computer first, then to the Storage. That is not a very smart solution.</p>



<p>So, I was trying to write a PowerShell Script that downloads Files directly via API to the offline Storage.</p>



<p>So here we are, Thanks to my colleague Ahmed, who already had a Function to renew Graph API Access token: <a href="https://github.com/uzejnovicahmed" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">uzejnovicahmed (Uzejnovic Ahmed)</a></p>



<h2 class="wp-block-heading">Preperations</h2>



<p>So first we need Access to our OneDrive via the GRAPH API, and for this we need an App Registration with the following Permissions.</p>



<ul class="wp-block-list">
<li>Files.ReadWrite.All ( for automation, I would recommend using Application Permission)</li>
</ul>



<pre class="wp-block-code"><code>#OneDrive GRAPH API Details
$clientID_OneDrive = "your Client ID"
$Clientsecret_OneDrive = "your Secret"
$tenantID = "Tenant ID"
</code></pre>



<p>Next, depending on your OneDrive Size and your bandwidth, the Backup will take some time, so we have to make sure our Access Token is renewed when it expires. I have to thank Ahmed for this part.</p>



<pre class="wp-block-code"><code>
#region functions
function Request-AccessToken {
    &#91;CmdletBinding()]
    param (
        &#91;Parameter(Mandatory = $true)] &#91;string]$TenantName,
        &#91;Parameter(Mandatory = $true)] &#91;string]$ClientId,
        &#91;Parameter(Mandatory = $true)] &#91;string]$ClientSecret
    )

    $tokenBody = @{
        Grant_Type    = 'client_credentials'
        Scope         = 'https://graph.microsoft.com/.default'
        Client_Id     = $ClientId
        Client_Secret = $ClientSecret
    }

    Write-Debug "Requesting a new access token from Microsoft Identity Platform..."

    try {
        $tokenResponse = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$TenantName/oauth2/v2.0/token" -Method POST -Body $tokenBody -ErrorAction Stop
        $global:accessToken = $tokenResponse.access_token
        $global:tokenExpiresAt = (Get-Date).AddSeconds($tokenResponse.expires_in)
        $global:headers = @{
            "Authorization" = "Bearer $($global:accessToken)"
            "Content-type"  = "application/json"
        }
    }
    catch {
        Write-Output "Error generating access token: $($_.Exception.Message)"
        Write-Output "Exception Details: $($_.Exception)"
        return $null
    }
    Write-Output "Successfully generated authentication token"
    return $tokenResponse
}
# Function to renew the access token when close to expiration
function Renew-AccessToken {
    param (
        &#91;string]$TenantName,
        &#91;string]$ClientId,
        &#91;string]$ClientSecret
    )

    Write-Debug "Attempting to renew the access token..."
    try {
        $tokenResponse = Request-AccessToken -TenantName $TenantName -ClientId $ClientId -ClientSecret $ClientSecret

        if ($null -ne $tokenResponse) {
            # Update the global access token and expiration time
            $global:accessToken = $tokenResponse.access_token
            $global:tokenExpiresAt = (Get-Date).AddSeconds($tokenResponse.expires_in)
            Write-Output "Token renewed successfully. New expiration time: $global:tokenExpiresAt"
        }
        else {
            Write-Output "Failed to renew the access token. Response was null."
        }
    }
    catch {
        Write-Output "Error renewing the access token: $($_.Exception.Message)"
    }
}
function Check-TokenExpiration {
    try {
        Write-Host "Checking token expiration at: $(Get-Date)..." 
        # Check if the token is about to expire (1 minute before expiration)
        if ((Get-Date) -ge $global:tokenExpiresAt.AddMinutes(-$minutesbeforetokenexpires)) {
            Write-Host "Access token is expired or close to expiration. Renewing the token..." -ForegroundColor Orange
            Renew-AccessToken -TenantName $tenantID -ClientId $clientID_OneDrive -ClientSecret $Clientsecret_OneDrive
        }
        else {
            Write-Host "Access token is still valid. Expires at: $global:tokenExpiresAt" -ForegroundColor Green
        }
    }
    catch {
        Write-Host "Error in Check-TokenExpiration function: $($_.Exception.Message)" -ForegroundColor Red
    }
}

#endregion functions


# Define global variables for the access token and expiration time
$global:accessToken = $null
$global:tokenExpiresAt = &#91;datetime]::MinValue
$global:headers = $null
$tokencheckinterval = 300000  # 300 seconds (300000 milliseconds) -&gt; Can be bigger in production.
$minutesbeforetokenexpires = 6 # Set how many minutes before token expiration the token should be renewed

# Request the initial token
$tokenResponse = Request-AccessToken -TenantName $tenantID -ClientId $clientID_OneDrive -ClientSecret $Clientsecret_OneDrive

#This is the Interval the  Token Check Takes place ! 
$timer = New-Object Timers.Timer
$timer.Interval = $tokencheckinterval
$Aktion = { Check-TokenExpiration }            
            
# Register the event handler to check token expiration
try {
    $timerEvent = Register-ObjectEvent -InputObject $timer -EventName Elapsed -SourceIdentifier "TokenCheck" -Action $Aktion
    Write-Output "Event registered successfully."
}
catch {
    Write-Output "Failed to register the timer event: $($_.Exception.Message)"
}

# Start the timer and verify that it is running
$timer.Start()
if ($timer.Enabled) {
    Write-Output "Timer started successfully. Access token will be checked for renewal every $($timer.Interval/1000) seconds."
}
else {
    Write-Output "Failed to start the timer."
}
</code></pre>



<p>Now we can learn about the Basic Settings and our OneDrive Details. This Example Script is limited to my personal OneDrive, but of course, it can be adapted to save others and shared OneDrives, too.</p>



<p>So we are configuring the Destination and the OneDrive we want to back up. replace the &#8220;*yourUPN*&#8221; </p>



<pre class="wp-block-code"><code>#Destionation Folder
$Dest = "Y:\OneDrive - Michael Seidl"

#OneDrive Details
$Drive = Invoke-RestMethod -Uri "https://graph.microsoft.com/v1.0/users/*yourUPN*/drive" -Method GET -Headers $global:headers
$Child = Invoke-RestMethod -Uri "https://graph.microsoft.com/v1.0/users/*yourUPN*/drives/$($Drive.id)/root/children" -Method GET -Headers $global:headers

</code></pre>



<p>Now we are coming to the tricky part, which took me some time. We got the first root content, like Files and Folders. </p>



<p>Doing a foreach and checking if it is a File or Folder.</p>



<p>If Folder, let&#8217;s check if it exists and create it.</p>



<p>If a File, check if it does not exist, or when it was last changed. In some cases, download the file.</p>



<p></p>



<p>Everything should be in a single loop because I do not know how many subfolders I have. So this was the first one I worked with: calling a Function within the Function itself.</p>



<p>Luckily, it works. On Top, we are creating a Job for each download, so we can go ahead and check the following files without waiting for the download to be finished.</p>



<pre class="wp-block-code"><code>

Function Download-Item {
    param (
        &#91;object]$ItemObject,
        &#91;hashtable]$Headers
    )
    $ItemID = $ItemObject.id

    if ($ItemObject.folder -ne $null) {
        #Folder
        $ParentFolder = "$Dest\$($ItemObject.parentReference.path.Split("root:/")&#91;1])"
        if (-not (Test-Path -Path $ParentFolder)) {
            New-Item -ItemType Directory -Path $ParentFolder -Force | Out-Null
        }
        $SubItemObject = Invoke-RestMethod -Uri "https://graph.microsoft.com/v1.0/users/michael.seidl@au2mator.com/drives/$($Drive.id)/items/$($ItemID)/children" -Method GET -Headers $global:headers
        foreach ($item in $SubItemObject.value | Sort-Object -Property size -Descending) {
            Download-Item -ItemObject $item -Headers $global:headers
        }           
    }
    elseif ($ItemObject.file -ne $null) {
        #File
        $ParentFolder = "$Dest\$($ItemObject.parentReference.path.Split("root:/")&#91;1])"
        $ParentFolder = $ParentFolder.Replace("/$($ItemObject.name)", '')
        if (-not (Test-Path -Path $ParentFolder)) {
            New-Item -ItemType Directory -Path $ParentFolder -Force | Out-Null
        }

        $ParentFolder = "$ParentFolder\$($ItemObject.name)"
        $Download = $false
        try {
            $LocalFile = Get-Item -Path $ParentFolder -ErrorAction Stop
            if ($LocalFile -and ($LocalFile.LastWriteTime -lt $ItemObject.lastModifiedDateTime)) {
                $Download = $true
            }
        }
        catch {
            $Download = $true
        }

        if ($Download) {
            write-Output "Downloading File: $($ItemObject.name) to $ParentFolder"
            Start-Job  -ScriptBlock {
                param($ItemID, $Headers, $ParentFolder, $Drive)
                Invoke-RestMethod -Uri "https://graph.microsoft.com/v1.0/users/michael.seidl@au2mator.com/drives/$($Drive.id)/items/$($ItemID)/content" -Method GET -Headers $Headers -OutFile $ParentFolder
            } -ArgumentList $ItemID, $Headers, $ParentFolder, $Drive | Out-Null
        }
    }
    else {  
    }    
}


#Main part
foreach ($item in $Child.value | Sort-Object -Property size -Descending) {
    Download-Item -ItemObject $item  -Headers $headers 
}
</code></pre>



<p></p>



<p>At the end, we are stopping the Timer Job.</p>



<pre class="wp-block-code"><code>
# Stop the timer and unregister the event when done
Write-Output "Stopping the timer and unregistering the event..."
$timer.Stop()
Unregister-Event -SourceIdentifier "TokenCheck"
$timer.Dispose()
Write-Output "Timer stopped. Final Access Token Expiration: $global:tokenExpiresAt"</code></pre>



<p></p>



<p>So, this might not yet be perfect, but it helps me to do my Backups so that it might help you as well.</p>



<p>This script took me some time; if this were a paid customer project, it would cost around 2.000 euros, and you get this for free. You can show your support by being a GitHub Sponsor: <a href="https://github.com/sponsors/Seidlm" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">Sponsor @Seidlm on GitHub Sponsors</a></p>



<p>The complete and updated script is here in my GitHub Repo: <a href="https://github.com/Seidlm/Microsoft-Graph-API-Examples" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">Seidlm/Microsoft-Graph-API-Examples</a></p>



<p>Michael Seidl, aka Techguy<br>au2mate everything</p>



<p></p>
<p>The post <a href="https://www.techguy.at/onedrive-offline-backup-with-powershell-and-graph-api/" data-wpel-link="internal">OneDrive offline Backup with PowerShell and GRAPH API</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->
<p>Releated Posts:<ol>
<li><a href="https://www.techguy.at/send-a-onedrive-file-via-mail-with-ms-graph-api-and-powershell/" rel="bookmark" title="Send a OneDrive File via Mail with MS GRAPH API and Powershell" data-wpel-link="internal">Send a OneDrive File via Mail with MS GRAPH API and Powershell</a> <small>Recently, I automated our invoice sending and automatically uploaded the...</small></li>
<li><a href="https://www.techguy.at/upload-a-file-to-onedrive-via-graph-api-and-powershell/" rel="bookmark" title="Upload a File to OneDrive via Graph API and PowerShell" data-wpel-link="internal">Upload a File to OneDrive via Graph API and PowerShell</a> <small>Recently, I upgraded my Invoicing automation, so I create Invoices...</small></li>
<li><a href="https://www.techguy.at/use-microsoft-graph-api-with-powershell-part-2/" rel="bookmark" title="Use Microsoft Graph API with PowerShell – Part 2" data-wpel-link="internal">Use Microsoft Graph API with PowerShell – Part 2</a> <small>You read the second Part in this Series, where we...</small></li>
<li><a href="https://www.techguy.at/assign-a-user-to-an-azure-resource-group-role-with-powershell-and-ms-graph-api/" rel="bookmark" title="Assign a User to an Azure Resource Group Role with PowerShell and MS Graph API" data-wpel-link="internal">Assign a User to an Azure Resource Group Role with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
<li><a href="https://www.techguy.at/powershell-custom-install-module-function/" rel="bookmark" title="PowerShell custom Install Module Function" data-wpel-link="internal">PowerShell custom Install Module Function</a> <small>Usually, it is simple to run &#8220;Install-Module,&#8221; and the module...</small></li>
</ol></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.techguy.at/onedrive-offline-backup-with-powershell-and-graph-api/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">6288</post-id>	</item>
		<item>
		<title>Disable IE for PowerShell Authentication Requests</title>
		<link>https://www.techguy.at/disable-ie-for-powershell-authentication-requests/</link>
					<comments>https://www.techguy.at/disable-ie-for-powershell-authentication-requests/#respond</comments>
		
		<dc:creator><![CDATA[Michael Seidl]]></dc:creator>
		<pubDate>Tue, 24 Jun 2025 08:25:24 +0000</pubDate>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[Powershell]]></category>
		<guid isPermaLink="false">https://www.techguy.at/?p=6272</guid>

					<description><![CDATA[<p>This will be a short Post, but I solved something that often caused trouble. I recently wanted to change some Azure Sync settings on my local DC, so I had to execute a Command, which then used IE to authenticate, and that&#8217;s on a Server 2022 As you might know, IE is not very good [&#8230;]</p>
<p>The post <a href="https://www.techguy.at/disable-ie-for-powershell-authentication-requests/" data-wpel-link="internal">Disable IE for PowerShell Authentication Requests</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->

Releated Posts:<ol>
<li><a href="https://www.techguy.at/backup-and-restore-last-modified-date-for-scsm-change-requests/" rel="bookmark" title="Backup and Restore Last Modified Date for SCSM Change Requests" data-wpel-link="internal">Backup and Restore Last Modified Date for SCSM Change Requests</a> <small>This is a classic Post cause it is related to...</small></li>
<li><a href="https://www.techguy.at/query-sql-with-powershell-without-a-module/" rel="bookmark" title="Query SQL with PowerShell without a Module" data-wpel-link="internal">Query SQL with PowerShell without a Module</a> <small>Most of you should be aware of &#8220;Invoke-SQLCMD&#8221; to run...</small></li>
<li><a href="https://www.techguy.at/control-your-husqvarna-automower-with-powershell/" rel="bookmark" title="Control your Husqvarna Automower with PowerShell" data-wpel-link="internal">Control your Husqvarna Automower with PowerShell</a> <small>Last year I bought a new Lawn Mower, a Husqvarna...</small></li>
<li><a href="https://www.techguy.at/use-powershell-to-query-your-bosch-home-connect-devices/" rel="bookmark" title="Use PowerShell to query your Bosch Home Connect Devices" data-wpel-link="internal">Use PowerShell to query your Bosch Home Connect Devices</a> <small>Recently our Washdryer lost the function to dry, so we...</small></li>
<li><a href="https://www.techguy.at/remove-a-member-from-a-microsoft-teams-team-with-powershell-and-ms-graph-api/" rel="bookmark" title="Remove a Member from a Microsoft Teams Team with PowerShell and MS Graph API" data-wpel-link="internal">Remove a Member from a Microsoft Teams Team with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
</ol>
</div>
]]></description>
										<content:encoded><![CDATA[
<p>This will be a short Post, but I solved something that often caused trouble.</p>



<p>I recently wanted to change some Azure Sync settings on my local DC, so I had to execute a Command, which then used IE to authenticate, and that&#8217;s on a Server 2022</p>



<p>As you might know, IE is not very good at those things; honestly, it does not work.</p>



<p>So, I figured out how to remove that link and remove IE from the Server.</p>



<p>Run the following command in an Admin PowerShell Session</p>



<p>&#8220;dism /online /Remove-Capability /CapabilityName:Browser.InternetExplorer~~~~0.0.11.0&#8221;</p>



<p>Try again, and the Authentication Process will use your favorite Browser, Edge <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p>Michael Seidl aka Techguy<br>au2mate everything</p>



<p></p>
<p>The post <a href="https://www.techguy.at/disable-ie-for-powershell-authentication-requests/" data-wpel-link="internal">Disable IE for PowerShell Authentication Requests</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->
<p>Releated Posts:<ol>
<li><a href="https://www.techguy.at/backup-and-restore-last-modified-date-for-scsm-change-requests/" rel="bookmark" title="Backup and Restore Last Modified Date for SCSM Change Requests" data-wpel-link="internal">Backup and Restore Last Modified Date for SCSM Change Requests</a> <small>This is a classic Post cause it is related to...</small></li>
<li><a href="https://www.techguy.at/query-sql-with-powershell-without-a-module/" rel="bookmark" title="Query SQL with PowerShell without a Module" data-wpel-link="internal">Query SQL with PowerShell without a Module</a> <small>Most of you should be aware of &#8220;Invoke-SQLCMD&#8221; to run...</small></li>
<li><a href="https://www.techguy.at/control-your-husqvarna-automower-with-powershell/" rel="bookmark" title="Control your Husqvarna Automower with PowerShell" data-wpel-link="internal">Control your Husqvarna Automower with PowerShell</a> <small>Last year I bought a new Lawn Mower, a Husqvarna...</small></li>
<li><a href="https://www.techguy.at/use-powershell-to-query-your-bosch-home-connect-devices/" rel="bookmark" title="Use PowerShell to query your Bosch Home Connect Devices" data-wpel-link="internal">Use PowerShell to query your Bosch Home Connect Devices</a> <small>Recently our Washdryer lost the function to dry, so we...</small></li>
<li><a href="https://www.techguy.at/remove-a-member-from-a-microsoft-teams-team-with-powershell-and-ms-graph-api/" rel="bookmark" title="Remove a Member from a Microsoft Teams Team with PowerShell and MS Graph API" data-wpel-link="internal">Remove a Member from a Microsoft Teams Team with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
</ol></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.techguy.at/disable-ie-for-powershell-authentication-requests/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">6272</post-id>	</item>
		<item>
		<title>Find unique SamAccountName and UPN for User Onboarding with the Help of AI</title>
		<link>https://www.techguy.at/find-unique-samaccountname-and-upn-for-user-onboarding-with-the-help-of-ai/</link>
					<comments>https://www.techguy.at/find-unique-samaccountname-and-upn-for-user-onboarding-with-the-help-of-ai/#respond</comments>
		
		<dc:creator><![CDATA[Michael Seidl]]></dc:creator>
		<pubDate>Mon, 31 Mar 2025 17:37:49 +0000</pubDate>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[Powershell]]></category>
		<guid isPermaLink="false">https://www.techguy.at/?p=6257</guid>

					<description><![CDATA[<p>Every IT Admin who is responsible for User Onboarding will understand the struggle of finding a unique Login Name and UPN for new Users. Some combinations might also be offensive or embarrassing. Depending on your Name Schema, finding unique Names for &#8220;Finn Ucker&#8221; or &#8220;Peter Immel&#8221; could result in some &#8220;fun&#8221; Usernames, depending on your [&#8230;]</p>
<p>The post <a href="https://www.techguy.at/find-unique-samaccountname-and-upn-for-user-onboarding-with-the-help-of-ai/" data-wpel-link="internal">Find unique SamAccountName and UPN for User Onboarding with the Help of AI</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->

Releated Posts:<ol>
<li><a href="https://www.techguy.at/find-unique-samaccountname-and-upn-for-user-onboarding-in-ad-with-powershell/" rel="bookmark" title="Find unique SamAccountName and UPN for User Onboarding in AD with PowerShell" data-wpel-link="internal">Find unique SamAccountName and UPN for User Onboarding in AD with PowerShell</a> <small>As I am doing automatic User Onboarding/Offboarding very often, I...</small></li>
<li><a href="https://www.techguy.at/rename-ad-user-mit-powershell/" rel="bookmark" title="Rename AD User mit PowerShell" data-wpel-link="internal">Rename AD User mit PowerShell</a> <small> Heute mal wieder ein PowerShell Script zu Active Directory....</small></li>
<li><a href="https://www.techguy.at/ablaufdatum-des-passwortes-der-ad-user-mit-powershell-auslesen/" rel="bookmark" title="Ablaufdatum des Passwortes der AD User mit PowerShell auslesen" data-wpel-link="internal">Ablaufdatum des Passwortes der AD User mit PowerShell auslesen</a> <small> Im heutigen Artikel zeige ich euch ein Script, mit...</small></li>
<li><a href="https://www.techguy.at/create-azure-guest-user-with-powershell-and-ms-graph-api/" rel="bookmark" title="Create Azure Guest User with PowerShell and MS Graph API" data-wpel-link="internal">Create Azure Guest User with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
<li><a href="https://www.techguy.at/how-to-update-every-single-active-directory-user-attributes-with-powershell-part-2/" rel="bookmark" title="How to update every single Active Directory User Attributes with Powershell &#8211; Part 2" data-wpel-link="internal">How to update every single Active Directory User Attributes with Powershell &#8211; Part 2</a> <small>From time to time, I always struggle a little, on...</small></li>
</ol>
</div>
]]></description>
										<content:encoded><![CDATA[
<p>Every IT Admin who is responsible for User Onboarding will understand the struggle of finding a unique Login Name and UPN for new Users. Some combinations might also be offensive or embarrassing.</p>



<p>Depending on your Name Schema, finding unique Names for &#8220;<strong>Finn Ucker</strong>&#8221; or &#8220;<strong>Peter Immel</strong>&#8221; could result in some &#8220;fun&#8221; Usernames, depending on your Location and Language.</p>



<p>Here comes AI for help. I adopted my PowerShell script to check each combination and let AI decide if the Name is offensive, funny, known brand or embarrassing</p>



<p></p>



<h2 class="wp-block-heading">Examples</h2>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="800" height="73" src="https://www.techguy.at/wp-content/uploads/2025/03/image-2.png" alt="" class="wp-image-6258" srcset="https://www.techguy.at/wp-content/uploads/2025/03/image-2.png 800w, https://www.techguy.at/wp-content/uploads/2025/03/image-2-768x70.png 768w" sizes="(max-width: 800px) 100vw, 800px" /></figure>



<figure class="wp-block-image size-full"><img decoding="async" width="800" height="91" src="https://www.techguy.at/wp-content/uploads/2025/03/image-3.png" alt="" class="wp-image-6259" srcset="https://www.techguy.at/wp-content/uploads/2025/03/image-3.png 800w, https://www.techguy.at/wp-content/uploads/2025/03/image-3-768x87.png 768w" sizes="(max-width: 800px) 100vw, 800px" /></figure>



<figure class="wp-block-image size-full"><img decoding="async" width="1486" height="141" src="https://www.techguy.at/wp-content/uploads/2025/03/image-4.png" alt="" class="wp-image-6260" srcset="https://www.techguy.at/wp-content/uploads/2025/03/image-4.png 1486w, https://www.techguy.at/wp-content/uploads/2025/03/image-4-768x73.png 768w" sizes="(max-width: 1486px) 100vw, 1486px" /></figure>



<h2 class="wp-block-heading">Details</h2>



<p>Inspired by a Post from David Stein on <a href="https://www.linkedin.com/posts/ds0934_activity-7307263138008055808-4TeZ/?utm_source=share&amp;utm_medium=member_ios&amp;rcm=ACoAAACtIAgB4AlNq39eh2qOamiIW6L9LUuCoOQ" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">LinkedIn</a> and the usage of the PSAI Module from <a href="https://www.linkedin.com/in/douglasfinke/" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">Doug Finke</a>, I adopted my existing Script on Github to use AI to ensure that no offensive, funny, known brand, or embarrassing Usernames are returned.</p>



<p>Please see the PSAI Documentation on how to set it up. In my example, I am using Azure OpenAI.</p>



<h2 class="wp-block-heading">GitHub</h2>



<p>Repo: <a href="https://github.com/Seidlm/Active-Directory" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">Seidlm/Active-Directory</a><br>File: <a href="https://github.com/Seidlm/Active-Directory/blob/main/Find%20free%20SamAccountName%20and%20UPN.ps1" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">Find free SamAccountName and UPN.ps1</a></p>



<p>Michael Seidl aka Techguy<br>au2mate everything</p>
<p>The post <a href="https://www.techguy.at/find-unique-samaccountname-and-upn-for-user-onboarding-with-the-help-of-ai/" data-wpel-link="internal">Find unique SamAccountName and UPN for User Onboarding with the Help of AI</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->
<p>Releated Posts:<ol>
<li><a href="https://www.techguy.at/find-unique-samaccountname-and-upn-for-user-onboarding-in-ad-with-powershell/" rel="bookmark" title="Find unique SamAccountName and UPN for User Onboarding in AD with PowerShell" data-wpel-link="internal">Find unique SamAccountName and UPN for User Onboarding in AD with PowerShell</a> <small>As I am doing automatic User Onboarding/Offboarding very often, I...</small></li>
<li><a href="https://www.techguy.at/rename-ad-user-mit-powershell/" rel="bookmark" title="Rename AD User mit PowerShell" data-wpel-link="internal">Rename AD User mit PowerShell</a> <small> Heute mal wieder ein PowerShell Script zu Active Directory....</small></li>
<li><a href="https://www.techguy.at/ablaufdatum-des-passwortes-der-ad-user-mit-powershell-auslesen/" rel="bookmark" title="Ablaufdatum des Passwortes der AD User mit PowerShell auslesen" data-wpel-link="internal">Ablaufdatum des Passwortes der AD User mit PowerShell auslesen</a> <small> Im heutigen Artikel zeige ich euch ein Script, mit...</small></li>
<li><a href="https://www.techguy.at/create-azure-guest-user-with-powershell-and-ms-graph-api/" rel="bookmark" title="Create Azure Guest User with PowerShell and MS Graph API" data-wpel-link="internal">Create Azure Guest User with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
<li><a href="https://www.techguy.at/how-to-update-every-single-active-directory-user-attributes-with-powershell-part-2/" rel="bookmark" title="How to update every single Active Directory User Attributes with Powershell &#8211; Part 2" data-wpel-link="internal">How to update every single Active Directory User Attributes with Powershell &#8211; Part 2</a> <small>From time to time, I always struggle a little, on...</small></li>
</ol></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.techguy.at/find-unique-samaccountname-and-upn-for-user-onboarding-with-the-help-of-ai/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">6257</post-id>	</item>
		<item>
		<title>Using Azure Key Vault to store your Azure Automation Credentials and Secrets</title>
		<link>https://www.techguy.at/using-azure-key-vault-to-store-your-azure-automation-credentials-and-secrets/</link>
					<comments>https://www.techguy.at/using-azure-key-vault-to-store-your-azure-automation-credentials-and-secrets/#respond</comments>
		
		<dc:creator><![CDATA[Michael Seidl]]></dc:creator>
		<pubDate>Fri, 28 Mar 2025 05:03:48 +0000</pubDate>
				<category><![CDATA[Azure Automation]]></category>
		<category><![CDATA[Azure Autoamrion]]></category>
		<category><![CDATA[Azure KeyVault]]></category>
		<category><![CDATA[Managed Identity]]></category>
		<guid isPermaLink="false">https://www.techguy.at/?p=6250</guid>

					<description><![CDATA[<p>Recently, we successfully conducted a POC for a Customer to migrate away from Azure Automation Credentials and Variables and everything to Azure KeyVault. In this case, the Customer is using Azure Automation for Cloud Automation, an Azure VM as a Hybrid Worker for onPrem Automation, and local PS Script for that VM. So, we have [&#8230;]</p>
<p>The post <a href="https://www.techguy.at/using-azure-key-vault-to-store-your-azure-automation-credentials-and-secrets/" data-wpel-link="internal">Using Azure Key Vault to store your Azure Automation Credentials and Secrets</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->

Releated Posts:<ol>
<li><a href="https://www.techguy.at/mail-alerting-on-azure-automation-accounts/" rel="bookmark" title="Mail Alerting on Azure Automation Accounts" data-wpel-link="internal">Mail Alerting on Azure Automation Accounts</a> <small>We are working heavily with Azure Automation for our customers...</small></li>
<li><a href="https://www.techguy.at/another-breaking-change-in-agent-based-azure-hybrid-worker/" rel="bookmark" title="Another Breaking Change in Agent-based Azure Hybrid Worker" data-wpel-link="internal">Another Breaking Change in Agent-based Azure Hybrid Worker</a> <small>We already know, or should know, that Microsoft is deprecating...</small></li>
<li><a href="https://www.techguy.at/control-secrets-in-azure-app-reg-manage-azure-app-reg-with-powershell-and-msgraph-api-part-2/" rel="bookmark" title="Control Secrets in Azure App Reg &#8211; Manage Azure App Reg with PowerShell and MSGRAPH API &#8211; Part 2" data-wpel-link="internal">Control Secrets in Azure App Reg &#8211; Manage Azure App Reg with PowerShell and MSGRAPH API &#8211; Part 2</a> <small>This is the second part of this Blog Series on...</small></li>
<li><a href="https://www.techguy.at/monitor-your-azure-secrets-zerts-and-spns-expire-date-with-powershell/" rel="bookmark" title="Monitor your Azure Secrets, Zerts and SPN&#8217;s Expire Date with PowerShell" data-wpel-link="internal">Monitor your Azure Secrets, Zerts and SPN&#8217;s Expire Date with PowerShell</a> <small>Azure App Registrations are a secure way to provide Credentials...</small></li>
<li><a href="https://www.techguy.at/monitor-your-azure-secrets-zerts-and-spns-expire-date-with-powershell-now-with-an-exclude-list/" rel="bookmark" title="Monitor your Azure Secrets, Zerts and SPN&#8217;s Expire Date with PowerShell &#8211; now with an Exclude List" data-wpel-link="internal">Monitor your Azure Secrets, Zerts and SPN&#8217;s Expire Date with PowerShell &#8211; now with an Exclude List</a> <small>Azure App Registrations are a secure way to provide Credentials...</small></li>
</ol>
</div>
]]></description>
										<content:encoded><![CDATA[
<p>Recently, we successfully conducted a POC for a Customer to migrate away from Azure Automation Credentials and Variables and everything to Azure KeyVault.</p>



<p>In this case, the Customer is using Azure Automation for Cloud Automation, an Azure VM as a Hybrid Worker for onPrem Automation, and local PS Script for that VM. So, we have three ways to execute and do the Automation, and the goal was to have a simple and secure way to get the Secrets from Azure Key Vault.</p>



<h2 class="wp-block-heading">Authentication</h2>



<p>So, the first and maybe most important part is the Authentication, we have three scenarios in who the PS and AA Runbooks are triggered and executed (Cloud, Hybrid, OnPrem) and wanted to have a&#8221;single&#8221; way to authenticate and get the secret Values via Azure Key Vault.</p>



<p>So, the Azure Automation Runbooks are executed as follows</p>



<ul class="wp-block-list">
<li>The Automation Account is executing the AA Runbook in the Cloud</li>



<li>The Hybrid Worker is executing the AA Runbook on the Hybrid Worker</li>



<li>local PS Scripts are executed on the Hybrid Worker</li>
</ul>



<p>So, we are having 2 Identities that are executing the Automation</p>



<ul class="wp-block-list">
<li>The <strong>Automation Account</strong> is executing the AA Runbook in the Cloud</li>



<li>A <strong>Hybrid Worker</strong> is executing AA Runbook and OnPrme PS Files</li>
</ul>



<p>So let&#8217;s find a way to assign those two Identities permission to read our KeyVault; each of those identities has a &#8220;Managed Identity&#8221; in Azure, so let&#8217;s give the &#8220;Reader&#8221; Access to the Azure Key Vault.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1159" height="136" src="https://www.techguy.at/wp-content/uploads/2025/03/image-1.png" alt="" class="wp-image-6252" srcset="https://www.techguy.at/wp-content/uploads/2025/03/image-1.png 1159w, https://www.techguy.at/wp-content/uploads/2025/03/image-1-768x90.png 768w" sizes="auto, (max-width: 1159px) 100vw, 1159px" /></figure>



<p>In the above Screenshot, the first entry is my Automation Account, and the second one is my Hybrid Worker, in this case with Azure Arc-enabled OnPrem Server.</p>



<p>There might be some more detailed and better documentation for this. Still, all the Managed identities we talked about have a separate endpoint to get the authentication token we can use in our PowerShell script to &#8221; impersonate &#8221; the managed identity to which we assigned the reader role above.</p>



<p>More Details can be found here:</p>



<ul class="wp-block-list">
<li>Managed Identity for Automation Account: <a href="https://learn.microsoft.com/en-us/azure/app-service/overview-managed-identity?tabs=portal%2Chttp" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">Managed Identities &#8211; Azure App Service | Microsoft Learn</a></li>



<li>Managed Identity for Azure Arc: <a href="https://learn.microsoft.com/en-us/azure/azure-arc/servers/managed-identity-authentication" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">Authenticate against Azure resources with Azure Arc-enabled servers &#8211; Azure Arc | Microsoft Learn</a></li>



<li>Managed Identity for Azure VMS: <a href="https://learn.microsoft.com/en-us/azure/virtual-machines/instance-metadata-service?tabs=windows" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">Azure Instance Metadata Service for virtual machines &#8211; Azure Virtual Machines | Microsoft Learn</a></li>



<li></li>
</ul>



<p>So, for this, we need to query a separate and different endpoint to get our access token, which we can then use to authenticate against the Azure KeyVault to get the secret value.</p>



<p>The example here shows how to use it with an Azure Arc-enabled Server. The Script on Github combines all three of them into a single Function.</p>



<h2 class="wp-block-heading">Arc-enabled Server Example</h2>



<p>For Azure Arc enabled Server, our Endpoint is this</p>



<pre class="wp-block-code"><code>$ResourceURL = "https://vault.azure.net/&amp;api-version=2020-06-01"
$endpoint="http://localhost:40342/metadata/identity/oauth2/token?resource==$ResourceURL" </code></pre>



<p>When we call this endpoint, praise the result, and convert from JSON, we get the Access Token we can use further.</p>



<pre class="wp-block-code"><code>$global:AZKVResponse = &#91;System.Text.Encoding]::Default.GetString((Invoke-WebRequest -Method GET -Uri $endpoint -Headers @{Metadata = 'True' } -UseBasicParsing).RawContentStream.ToArray()) | ConvertFrom-Json</code></pre>



<p>So, in the Global Variable, we now have tTokenken stored, and we are now building the header to get the Value of our Secret.</p>



<p></p>



<pre class="wp-block-code"><code>$token = $global:AZKVResponse.access_token
$Return = Invoke-RestMethod -Uri "https://$($KeyVaultName).vault.azure.net/secrets/$($SecretName)?api-version=7.1" -Method GET -Headers @{Authorization = "Bearer $($token)" }
return $return.value</code></pre>



<p>In this example, our $KeyVaultName is the unique name from our Azure Key Vault, and the $SecretName is the Name of the Secret you are trying to read.</p>



<p>Summary</p>



<p>In my opinion, and I am definitely not a Security Expert, but I think this might be the best and most secure way to store and use Secrets with Automation.</p>



<ul class="wp-block-list">
<li>Only the ManagIdentityity, so the Server or Automation Account has Access to the Key Vault.</li>



<li>You are not forced to store Credentials locally for testing cause you can use the same code when executed in VS Code or in an Azure Automation Runbook</li>



<li>Only humans who have access to the Automation Account or the Hybrid Server have access to the Secrets, which is easy to control.</li>



<li>Many more&#8230;</li>
</ul>



<h2 class="wp-block-heading">GitHub</h2>



<p>I stored a single function you can use on GitHub. We also created a Global Variable for tTokenken to reduce the number of Calls, as there is a throttling limit for the local endpoints here. There might be a better version in the future, but let&#8217;s look at the version on GitHub for details.</p>



<p>Repo: <a href="https://github.com/Seidlm/Microsoft-Azure" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">Seidlm/Microsoft-Azure: Azure Rest/Graph API Examples</a><br>File: <a href="https://github.com/Seidlm/Microsoft-Azure/blob/main/Query%20Azure%20Key%20Vault.ps1" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">Query Azure Key Vault.ps1</a></p>



<p>Michael Seidl aka Techguy<br>au2mate everything</p>



<p></p>
<p>The post <a href="https://www.techguy.at/using-azure-key-vault-to-store-your-azure-automation-credentials-and-secrets/" data-wpel-link="internal">Using Azure Key Vault to store your Azure Automation Credentials and Secrets</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->
<p>Releated Posts:<ol>
<li><a href="https://www.techguy.at/mail-alerting-on-azure-automation-accounts/" rel="bookmark" title="Mail Alerting on Azure Automation Accounts" data-wpel-link="internal">Mail Alerting on Azure Automation Accounts</a> <small>We are working heavily with Azure Automation for our customers...</small></li>
<li><a href="https://www.techguy.at/another-breaking-change-in-agent-based-azure-hybrid-worker/" rel="bookmark" title="Another Breaking Change in Agent-based Azure Hybrid Worker" data-wpel-link="internal">Another Breaking Change in Agent-based Azure Hybrid Worker</a> <small>We already know, or should know, that Microsoft is deprecating...</small></li>
<li><a href="https://www.techguy.at/control-secrets-in-azure-app-reg-manage-azure-app-reg-with-powershell-and-msgraph-api-part-2/" rel="bookmark" title="Control Secrets in Azure App Reg &#8211; Manage Azure App Reg with PowerShell and MSGRAPH API &#8211; Part 2" data-wpel-link="internal">Control Secrets in Azure App Reg &#8211; Manage Azure App Reg with PowerShell and MSGRAPH API &#8211; Part 2</a> <small>This is the second part of this Blog Series on...</small></li>
<li><a href="https://www.techguy.at/monitor-your-azure-secrets-zerts-and-spns-expire-date-with-powershell/" rel="bookmark" title="Monitor your Azure Secrets, Zerts and SPN&#8217;s Expire Date with PowerShell" data-wpel-link="internal">Monitor your Azure Secrets, Zerts and SPN&#8217;s Expire Date with PowerShell</a> <small>Azure App Registrations are a secure way to provide Credentials...</small></li>
<li><a href="https://www.techguy.at/monitor-your-azure-secrets-zerts-and-spns-expire-date-with-powershell-now-with-an-exclude-list/" rel="bookmark" title="Monitor your Azure Secrets, Zerts and SPN&#8217;s Expire Date with PowerShell &#8211; now with an Exclude List" data-wpel-link="internal">Monitor your Azure Secrets, Zerts and SPN&#8217;s Expire Date with PowerShell &#8211; now with an Exclude List</a> <small>Azure App Registrations are a secure way to provide Credentials...</small></li>
</ol></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.techguy.at/using-azure-key-vault-to-store-your-azure-automation-credentials-and-secrets/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">6250</post-id>	</item>
		<item>
		<title>Monitor your Azure Secrets, Zerts and SPN&#8217;s Expire Date with PowerShell &#8211; now with an Exclude List</title>
		<link>https://www.techguy.at/monitor-your-azure-secrets-zerts-and-spns-expire-date-with-powershell-now-with-an-exclude-list/</link>
					<comments>https://www.techguy.at/monitor-your-azure-secrets-zerts-and-spns-expire-date-with-powershell-now-with-an-exclude-list/#respond</comments>
		
		<dc:creator><![CDATA[Michael Seidl]]></dc:creator>
		<pubDate>Tue, 25 Feb 2025 04:49:56 +0000</pubDate>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[Azure App Reg]]></category>
		<category><![CDATA[expire]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[servicePrincipals]]></category>
		<category><![CDATA[Zert]]></category>
		<guid isPermaLink="false">https://www.techguy.at/?p=6248</guid>

					<description><![CDATA[<p>Azure App Registrations are a secure way to provide Credentials and Access to the Azure World. The Amount of Azure App Registrations in a Tenant is increasing very fast, so it is not that easy to control and monitor all those Secrets, Zert, and SPN&#8217;s Expire Date. So I have written a PowerShell Script to [&#8230;]</p>
<p>The post <a href="https://www.techguy.at/monitor-your-azure-secrets-zerts-and-spns-expire-date-with-powershell-now-with-an-exclude-list/" data-wpel-link="internal">Monitor your Azure Secrets, Zerts and SPN&#8217;s Expire Date with PowerShell &#8211; now with an Exclude List</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->

Releated Posts:<ol>
<li><a href="https://www.techguy.at/monitor-your-azure-secrets-zerts-and-spns-expire-date-with-powershell/" rel="bookmark" title="Monitor your Azure Secrets, Zerts and SPN&#8217;s Expire Date with PowerShell" data-wpel-link="internal">Monitor your Azure Secrets, Zerts and SPN&#8217;s Expire Date with PowerShell</a> <small>Azure App Registrations are a secure way to provide Credentials...</small></li>
<li><a href="https://www.techguy.at/control-secrets-in-azure-app-reg-manage-azure-app-reg-with-powershell-and-msgraph-api-part-2/" rel="bookmark" title="Control Secrets in Azure App Reg &#8211; Manage Azure App Reg with PowerShell and MSGRAPH API &#8211; Part 2" data-wpel-link="internal">Control Secrets in Azure App Reg &#8211; Manage Azure App Reg with PowerShell and MSGRAPH API &#8211; Part 2</a> <small>This is the second part of this Blog Series on...</small></li>
<li><a href="https://www.techguy.at/delete-a-secret-from-an-azure-application-registration-with-powershell-and-ms-graph-api/" rel="bookmark" title="Delete a Secret from an Azure Application Registration with PowerShell and MS GRAPH API" data-wpel-link="internal">Delete a Secret from an Azure Application Registration with PowerShell and MS GRAPH API</a> <small>In this post, we will delete a Secret from an...</small></li>
<li><a href="https://www.techguy.at/add-a-secret-to-an-azure-application-registration-with-powershell-and-ms-graph-api/" rel="bookmark" title="Add a Secret to an Azure Application Registration with PowerShell and MS GRAPH API" data-wpel-link="internal">Add a Secret to an Azure Application Registration with PowerShell and MS GRAPH API</a> <small>In this post, we will create a Secret for an...</small></li>
<li><a href="https://www.techguy.at/remove-a-user-from-an-azure-resource-group-role-with-powershell-and-azure-rest-api/" rel="bookmark" title="Remove a User from an Azure Resource Group Role with PowerShell and Azure Rest API" data-wpel-link="internal">Remove a User from an Azure Resource Group Role with PowerShell and Azure Rest API</a> <small>In this post, I want to show you how to...</small></li>
</ol>
</div>
]]></description>
										<content:encoded><![CDATA[
<p>Azure App Registrations are a secure way to provide Credentials and Access to the Azure World. The Amount of Azure App Registrations in a Tenant is increasing very fast, so it is not that easy to control and monitor all those Secrets, Zert, and SPN&#8217;s Expire Date.</p>



<p>So I have written a PowerShell Script to send an Email, when an Azure App Secret or Zert, or an Azure SPN is expiring in the near future. This Script can be executed in your OnPrem data center or as an Azure Automation Runbook.<br><br>We added an ExcludeList with Wildcards, so you an add some App Names, where there will be no notification</p>



<h2 class="wp-block-heading" id="h-prerequisites">Prerequisites</h2>



<p>First, we need to create an Azure App to provide all the permissions required. Yes, that one will also be monitored by the Script <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p><strong>MS Graph References:</strong></p>



<ul class="wp-block-list">
<li><a href="https://docs.microsoft.com/en-us/graph/api/application-list?view=graph-rest-1.0&amp;tabs=http" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">List applications &#8211; Microsoft Graph v1.0 | Microsoft Docs</a></li>



<li><a href="https://docs.microsoft.com/en-us/graph/api/serviceprincipal-list?view=graph-rest-1.0&amp;tabs=http" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">List servicePrincipals &#8211; Microsoft Graph v1.0 | Microsoft Docs</a></li>
</ul>



<p><strong>Create an Azure App Registration and add the following GRAPH API Application Permissions</strong></p>



<ul class="wp-block-list">
<li>Application.Read.All</li>



<li>Application.ReadWrite.All</li>



<li>Directory.Read.All</li>



<li>User.Read</li>
</ul>



<p><strong>Create a Secret and copy the Value</strong></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>If your are not familiar with Azur eapp Regs, and how als this work together, see my Blogs Post for Details:</p>



<p><em>To learn more from Microsoft GRAPH API, see my Blog Series:</em><br><em>Part 1 – Authentication and Azure App – </em><a href="https://www.techguy.at/use-microsoft-graph-api-with-powershell-part-1/" data-wpel-link="internal">Use Microsoft Graph API with PowerShell – Part 1 » TechGuy</a><br><em>Part 2 – Oauth2.0 – </em><a href="https://www.techguy.at/use-microsoft-graph-api-with-powershell-part-2/" data-wpel-link="internal">Use Microsoft Graph API with PowerShell – Part 2 » TechGuy</a><br><em>Part 3 – First Powershell Script to get a Teams Lis and Walkthrough – </em><a href="https://www.techguy.at/use-microsoft-graph-api-with-powershell-part-3/" data-wpel-link="internal">Use Microsoft Graph API with PowerShell – Part 3 » TechGuy</a><br><em>Part 4 – this one – </em><a href="https://www.techguy.at/use-microsoft-graph-api-with-powershell-part-4/" data-wpel-link="internal">Use Microsoft Graph API with PowerShell – Part 4 » TechGuy</a></p>
</blockquote>



<p>Second, we are sending an Email using Graph API, so see my previous Blog Post for Details and Enter the GRAPH Details in the Script: <a href="https://www.techguy.at/send-mail-with-powershell-and-microsoft-graph-api/" data-wpel-link="internal">Send Mail with PowerShell and Microsoft Graph API &#8211; TechGuy</a></p>



<p>With all this information, we can take a look at the Script</p>



<h2 class="wp-block-heading">The Script</h2>



<p>Please fill in Settings and the Azure App Details til the Line &#8220;#STOP HERE&#8221;</p>



<p>The Script will send you an email for each Azure App or SP, which will expire within the next 90 Days ($TimeSpanInDays). </p>



<p>Already expired ones will not trigger an Email</p>



<p>The Variable $ExcludedList can be used to add Names with Wildcards, those App will be ignored</p>



<pre class="wp-block-code"><code>#Settings
$TimeSpanInDays = 90
$MailSender = "Mail Sender Mail"
$MailRecipient = "Mail Recipient Mail"

#Azure App Credentials to get Apps and SP
$EXPIRE_AppId = "your EXPIRE APP Client ID"
$EXPIRE_secret = "your EXPIRE APP Secret"

$tenantID = "Azure Tenant ID"

#Azure App Credentials to send the Mail
$MAIL_AppId = "your Mail Client ID"
$MAIL_secret = "your Mail Secret"

#ExcludeList
$ExcludedList = "*(Power Virtual Agents);*(Microsoft Copilot Studio);RSC-CAM-Einfahrt"
$ExcludedListArray = $ExcludedList -split ";"


#STOP HERE!

#Connect to GRAPH API with EXPIRE credentials
$EXPIRE_tokenBody = @{
    Grant_Type    = "client_credentials"
    Scope         = "https://graph.microsoft.com/.default"
    Client_Id     = $EXPIRE_AppId
    Client_Secret = $EXPIRE_secret
}
$EXPIRE_tokenResponse = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$tenantID/oauth2/v2.0/token" -Method POST -Body $EXPIRE_tokenBody
$EXPIRE_headers = @{
    "Authorization" = "Bearer $($EXPIRE_tokenResponse.access_token)"
    "Content-type"  = "application/json"
}



#Connect to GRAPH API with MAIL Credentials
$MAIL_tokenBody = @{
    Grant_Type    = "client_credentials"
    Scope         = "https://graph.microsoft.com/.default"
    Client_Id     = $MAIL_AppId
    Client_Secret = $MAIL_secret
}
$MAIL_tokenResponse = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$tenantID/oauth2/v2.0/token" -Method POST -Body $MAIL_tokenBody
$MAIL_headers = @{
    "Authorization" = "Bearer $($MAIL_tokenResponse.access_token)"
    "Content-type"  = "application/json"
}


#functions
function Get-AzureResourcePaging {
    param (
        $URL,
        $AuthHeader
    )

    # List Get all Apps from Azure

    $Response = Invoke-RestMethod -Method GET -Uri $URL -Headers $AuthHeader
    $Resources = $Response.value

    $ResponseNextLink = $Response."@odata.nextLink"
    while ($ResponseNextLink -ne $null) {

        $Response = (Invoke-RestMethod -Uri $ResponseNextLink -Headers $AuthHeader -Method Get)
        $ResponseNextLink = $Response."@odata.nextLink"
        $Resources += $Response.value
    }
    return $Resources
}


#Build Array to store PSCustomObject
$Array = @()



# List Get all Apps from Azure
$URLGetApps = "https://graph.microsoft.com/v1.0/applications"
$AllApps = Get-AzureResourcePaging -URL $URLGetApps -AuthHeader $EXPIRE_headers


#Go through each App and add to our Array
foreach ($App in $AllApps) {

    $URLGetApp = "https://graph.microsoft.com/v1.0/applications/$($App.ID)"
    $App = Invoke-RestMethod -Method GET -Uri $URLGetApp -Headers $EXPIRE_headers

    if ($App.passwordCredentials) {
        foreach ($item in $App.passwordCredentials) {
            $Array += &#91;PSCustomObject]@{
                "Type"           = "AZAPP"
                "displayName"    = $app.displayName
                "ID"             = $App.ID
                "AppID"          = $app.appId
                "SecType"        = "Secret"
                "Secret"         = $item.displayName
                "Secret-EndDate" = (Get-date $item.endDateTime)
            }
        }
    }


    if ($App.keyCredentials) {
        foreach ($item in $App.keyCredentials) {
            $Array += &#91;PSCustomObject]@{
                'Type'           = "AZAPP"
                'displayName'    = $app.displayName
                'ID'             = $App.ID
                'AppID'          = $app.appId
                'SecType'        = "Zert"
                'Secret'         = $item.displayName
                'Secret-EndDate' = (Get-date $item.endDateTime)
            }
        }
    }
}




#Get all Service Principals
$servicePrincipals = "https://graph.microsoft.com/v1.0/servicePrincipals"
$SPList = Get-AzureResourcePaging -URL $servicePrincipals -AuthHeader $EXPIRE_headers


#Go through each SP and add to our Array
foreach ($SAML in $SPList) {
    if ($Saml.passwordCredentials) {
        foreach ($PW in $Saml.passwordCredentials) {
            $Array += &#91;PSCustomObject]@{
                'Type'           = "SP"
                'displayName'    = $SAML.displayName
                'ID'             = $SAML.id
                'AppID'          = $Saml.appId
                'SecType'        = "Secret"
                'Secret'         = $PW.displayName
                'Secret-EndDate' = (Get-date $PW.endDateTime)
            }
        }
    }
}



$ExpireringZerts = $Array | Where-Object -Property Secret-EndDate -Value (Get-Date).AddDays($TimeSpanInDays) -lt  | Where-Object -Property Secret-EndDate -Value (Get-Date) -gt

foreach ($Zert in $ExpireringZerts) {
    $Exclude = $False
    foreach ($Entry in $ExcludedListArray) {
        if ($Zert.displayName -like $Entry) {
            $Exclude = $True
        }
    }
    if ($Exclude) {
        #do nothing
    }
    else {

        $HTML = $Zert | Convertto-HTML -Fragment -As List

        $URLsend = "https://graph.microsoft.com/v1.0/users/$MailSender/sendMail"

        $BodyJsonsend = @"
                        {
                            "message": {
                              "subject": "Azure App or SPN will expire soon $($Zert.displayName)",
                              "body": {
                                "contentType": "HTML",
                                "content": "$HTML
                                &lt;br>
                                Michael Seidl (au2mator)
                                &lt;br>

                                "
                              },
                              "toRecipients": &#91;
                                {
                                  "emailAddress": {
                                    "address": "$MailRecipient"
                                  }
                                }
                              ]
                            },
                            "saveToSentItems": "false"
                          }
"@

        Invoke-RestMethod -Method POST -Uri $URLsend -Headers $MAIL_headers -Body $BodyJsonsend
    }
}</code></pre>



<h2 class="wp-block-heading">GitHub Repo</h2>



<p>Here you can find the GitHub Repo:&nbsp;<a href="https://github.com/Seidlm/Microsoft-Graph-API-Examples" target="_blank" rel="noreferrer noopener follow" data-wpel-link="external"></a><a href="https://github.com/Seidlm/Microsoft-Azure" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">Seidlm/Microsoft-Azure: Azure Rest API Examples (github.com)</a> with the Script</p>



<p>Michael Seidl aka Techguy<br>au2mate everything</p>
<p>The post <a href="https://www.techguy.at/monitor-your-azure-secrets-zerts-and-spns-expire-date-with-powershell-now-with-an-exclude-list/" data-wpel-link="internal">Monitor your Azure Secrets, Zerts and SPN&#8217;s Expire Date with PowerShell &#8211; now with an Exclude List</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->
<p>Releated Posts:<ol>
<li><a href="https://www.techguy.at/monitor-your-azure-secrets-zerts-and-spns-expire-date-with-powershell/" rel="bookmark" title="Monitor your Azure Secrets, Zerts and SPN&#8217;s Expire Date with PowerShell" data-wpel-link="internal">Monitor your Azure Secrets, Zerts and SPN&#8217;s Expire Date with PowerShell</a> <small>Azure App Registrations are a secure way to provide Credentials...</small></li>
<li><a href="https://www.techguy.at/control-secrets-in-azure-app-reg-manage-azure-app-reg-with-powershell-and-msgraph-api-part-2/" rel="bookmark" title="Control Secrets in Azure App Reg &#8211; Manage Azure App Reg with PowerShell and MSGRAPH API &#8211; Part 2" data-wpel-link="internal">Control Secrets in Azure App Reg &#8211; Manage Azure App Reg with PowerShell and MSGRAPH API &#8211; Part 2</a> <small>This is the second part of this Blog Series on...</small></li>
<li><a href="https://www.techguy.at/delete-a-secret-from-an-azure-application-registration-with-powershell-and-ms-graph-api/" rel="bookmark" title="Delete a Secret from an Azure Application Registration with PowerShell and MS GRAPH API" data-wpel-link="internal">Delete a Secret from an Azure Application Registration with PowerShell and MS GRAPH API</a> <small>In this post, we will delete a Secret from an...</small></li>
<li><a href="https://www.techguy.at/add-a-secret-to-an-azure-application-registration-with-powershell-and-ms-graph-api/" rel="bookmark" title="Add a Secret to an Azure Application Registration with PowerShell and MS GRAPH API" data-wpel-link="internal">Add a Secret to an Azure Application Registration with PowerShell and MS GRAPH API</a> <small>In this post, we will create a Secret for an...</small></li>
<li><a href="https://www.techguy.at/remove-a-user-from-an-azure-resource-group-role-with-powershell-and-azure-rest-api/" rel="bookmark" title="Remove a User from an Azure Resource Group Role with PowerShell and Azure Rest API" data-wpel-link="internal">Remove a User from an Azure Resource Group Role with PowerShell and Azure Rest API</a> <small>In this post, I want to show you how to...</small></li>
</ol></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.techguy.at/monitor-your-azure-secrets-zerts-and-spns-expire-date-with-powershell-now-with-an-exclude-list/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">6248</post-id>	</item>
		<item>
		<title>Behind the Scenes: Podcast Equipment and Automation Techniques</title>
		<link>https://www.techguy.at/behind-the-scenes-podcast-equipment-and-automation-techniques/</link>
					<comments>https://www.techguy.at/behind-the-scenes-podcast-equipment-and-automation-techniques/#respond</comments>
		
		<dc:creator><![CDATA[Michael Seidl]]></dc:creator>
		<pubDate>Mon, 18 Nov 2024 09:59:57 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[Podcast]]></category>
		<guid isPermaLink="false">https://www.techguy.at/?p=6217</guid>

					<description><![CDATA[<p>In my recent podcast episode, I discussed how my podcast was produced. This is the written version of my Equipment and Workflow. Ideas So, I get my ideas for the podcast from my community or my sessions. I started a year ago with my first &#8220;non Technical&#8221; session, &#8220;Get Sh*t done in IT,&#8221; and this [&#8230;]</p>
<p>The post <a href="https://www.techguy.at/behind-the-scenes-podcast-equipment-and-automation-techniques/" data-wpel-link="internal">Behind the Scenes: Podcast Equipment and Automation Techniques</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->

Releated Posts:<ol>
<li><a href="https://www.techguy.at/geeksprech-podcast-talk-about-scsm-and-automation/" rel="bookmark" title="Geeksprech Podcast Talk about SCSM and Automation" data-wpel-link="internal">Geeksprech Podcast Talk about SCSM and Automation</a> <small>Hi, i have been invited by Eric Berg and Alexander...</small></li>
<li><a href="https://www.techguy.at/mein-erstes-interview/" rel="bookmark" title="Mein erstes Interview" data-wpel-link="internal">Mein erstes Interview</a> <small>Vor einigen Woche bat mich Carsten Rachfahl um ein Interview...</small></li>
<li><a href="https://www.techguy.at/1-year-notion-or-how-au2mator-is-doing-internal-automation/" rel="bookmark" title="1-Year Notion, or how au2mator is doing internal automation." data-wpel-link="internal">1-Year Notion, or how au2mator is doing internal automation.</a> <small>This article could be more technical. It should show how...</small></li>
<li><a href="https://www.techguy.at/webcast-get-more-with-system-center-and-au2mator/" rel="bookmark" title="Webcast &#8211; Get more with System Center and au2mator" data-wpel-link="internal">Webcast &#8211; Get more with System Center and au2mator</a> <small>See our latest Webcast Recording &#8211; Get more with System...</small></li>
<li><a href="https://www.techguy.at/techguy-goes-youtube/" rel="bookmark" title="Techguy goes YouTube" data-wpel-link="internal">Techguy goes YouTube</a> <small>Richtig gelesen, Techguy ist nun auch auf YouTube. Vielleicht habt...</small></li>
</ol>
</div>
]]></description>
										<content:encoded><![CDATA[
<p>In my recent podcast episode, I discussed how my podcast was produced.</p>



<p>This is the written version of my Equipment and Workflow.</p>



<h2 class="wp-block-heading">Ideas</h2>



<p>So, I get my ideas for the podcast from my community or my sessions. I started a year ago with my first &#8220;non Technical&#8221; session, &#8220;Get Sh*t done in IT,&#8221; and this was the beginning of my Podcast. I still do that session, and I get the feedback and Questions that I am trying to put in my Podcast. </p>



<p>Also, People are writing to me on LinkedIn and asking Questions about my Podcast.</p>



<p>I also bring my own ideas in for some episodes.</p>



<p>However, the main goal is to produce a podcast for the community.</p>



<h2 class="wp-block-heading">Equipment</h2>



<p>My recent Equipment looks like this, but this is constantly changing, as I am just a techy nerd and always try something new <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<ul class="wp-block-list">
<li><a href="https://amzn.to/3CwlTmJ" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">Elgato Teleprompter with Facecam Pro</a> (For 4k Video Recording and Exe Contact)</li>



<li><a href="https://amzn.to/3ObwmXh" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">2 Elgator Key Lights </a>behind my Monitor (Better Lights in my Room for recording)</li>



<li><a href="https://www.amazon.de/dp/B00N1YPXW2/ref=cm_sw_r_as_gl_api_gl_i_B26Y2A3C9ETAXMWWSKFC?linkCode=ml2&amp;tag=techguy-21" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">YETI Blue USB Microphone</a> (perfect Audio)</li>



<li>Apple Mac Book (it just feels better <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> )</li>



<li>and some Mounts</li>
</ul>



<p>I am also working on a mobile Set right now, I will keep you updated.</p>



<h2 class="wp-block-heading">Workflow</h2>



<p>My Workflow was very important from the beginning, as I wanted to reduce production time to a minimum. I only chose Platforms and tools with an API to automate as much as possible.<br>Let&#8217;s see the Process. </p>



<h3 class="wp-block-heading">Idea</h3>



<p>My Ideas and notes are stored in <a href="https://affiliate.notion.so/62ygp3zh4w1a" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">Notion</a>. So there are Ideas for future Episodes and all Details for my past Episodes, which are synced automatically with Azure Automation to Podigee.</p>



<h3 class="wp-block-heading">Recording</h3>



<p>I use <a href="https://riverside.fm/?utm_campaign=campaign_2&amp;utm_medium=affiliate&amp;utm_source=rewardful&amp;via=michael-seidl" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external"><strong>Riverside.fm</strong></a> to record my Podcast. The benefit is that Riverside is taking care of the Audio and Video, so I ran some AI magic, and my Video and Audio are fine.</p>



<h3 class="wp-block-heading">Audio Production</h3>



<p>Finally, I am using Adobe Audition to produce the audio file. Here, I have to record the &#8220;Hook Phrase&#8221; at the beginning, and I arrange INTRO and OUTRO. The result is the ready to use Audio File, which I can Upload to my Podcast Hoster</p>



<h3 class="wp-block-heading">Podcast Hoster</h3>



<p>For this, I use Podigee, so the Episodes are automatically synced from Notion to Podigee via API; I only have to upload the final Audio File, and that&#8217;s it.</p>



<h3 class="wp-block-heading">Social Media</h3>



<p>To promote my Podcast, I use shot Videos to publish on TikTok, Instagram, Twitter, YouTube, and LinkedIn. To create these short Videos, I use <a href="https://www.opus.pro/?via=d965b0" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external"><strong>Opus CLIP Pro</strong></a>, which takes a full-length video and automatically creates short videos with AI. I got around 5-7 Short Videos out of a Podcast Episode in each Language.</p>



<p>Those Videos are then downloaded and finished with Adobe Premier Rush to add an INTRO and OUTRO.</p>



<p>Finally, I uploaded the video to a <a href="https://affiliate.notion.so/62ygp3zh4w1a" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">Notion </a>Table, where I planned the social media posts. Then, they are synced and planned with Azure Automation to<strong> <a href="https://i.mtrbio.com/VYCNAV" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">Metricool</a></strong>.</p>



<h2 class="wp-block-heading">Result</h2>



<p>So, the result is that I produce a double Episode (English and German) of about <strong>10-15 Minutes</strong> each in <strong>about 1 Hour</strong></p>



<p></p>



<p><strong>5 Minutes</strong>: Ideas and some preparations</p>



<p>up to <strong>30 Minutes</strong> for recording (15 min each language)</p>



<p><strong>10 Minutes</strong> Audio Production</p>



<p><strong>10 Minutes</strong> Video Production</p>



<p><strong>5 Minutes Social Media Planning</strong></p>



<p></p>



<p>That&#8217;s it; that&#8217;s the &#8220;Magic&#8221; behind my Podcast. Let me know if you have any improvements.</p>



<p></p>



<p></p>



<h2 class="wp-block-heading">PODCAST RECORDING</h2>



<figure class="wp-block-table"><table style="height:300px"><tbody><tr><td>

<iframe loading="lazy" src="https://get-sht-done-en.podigee.io/embed?context=external" style="border: 0" border="0" height="300" width="100%"></iframe>

</td><td>

<iframe loading="lazy" src="https://get-sht-done-de.podigee.io/embed?context=external" style="border: 0" border="0" height="300" width="100%"></iframe>

</td></tr></tbody></table></figure>



<p>Michael Seidl aka Techguy<br>au2mate everything<br><br>PS: Some Links might be Affiliate Links</p>
<p>The post <a href="https://www.techguy.at/behind-the-scenes-podcast-equipment-and-automation-techniques/" data-wpel-link="internal">Behind the Scenes: Podcast Equipment and Automation Techniques</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->
<p>Releated Posts:<ol>
<li><a href="https://www.techguy.at/geeksprech-podcast-talk-about-scsm-and-automation/" rel="bookmark" title="Geeksprech Podcast Talk about SCSM and Automation" data-wpel-link="internal">Geeksprech Podcast Talk about SCSM and Automation</a> <small>Hi, i have been invited by Eric Berg and Alexander...</small></li>
<li><a href="https://www.techguy.at/mein-erstes-interview/" rel="bookmark" title="Mein erstes Interview" data-wpel-link="internal">Mein erstes Interview</a> <small>Vor einigen Woche bat mich Carsten Rachfahl um ein Interview...</small></li>
<li><a href="https://www.techguy.at/1-year-notion-or-how-au2mator-is-doing-internal-automation/" rel="bookmark" title="1-Year Notion, or how au2mator is doing internal automation." data-wpel-link="internal">1-Year Notion, or how au2mator is doing internal automation.</a> <small>This article could be more technical. It should show how...</small></li>
<li><a href="https://www.techguy.at/webcast-get-more-with-system-center-and-au2mator/" rel="bookmark" title="Webcast &#8211; Get more with System Center and au2mator" data-wpel-link="internal">Webcast &#8211; Get more with System Center and au2mator</a> <small>See our latest Webcast Recording &#8211; Get more with System...</small></li>
<li><a href="https://www.techguy.at/techguy-goes-youtube/" rel="bookmark" title="Techguy goes YouTube" data-wpel-link="internal">Techguy goes YouTube</a> <small>Richtig gelesen, Techguy ist nun auch auf YouTube. Vielleicht habt...</small></li>
</ol></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.techguy.at/behind-the-scenes-podcast-equipment-and-automation-techniques/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">6217</post-id>	</item>
		<item>
		<title>Mail Alerting on Azure Automation Accounts</title>
		<link>https://www.techguy.at/mail-alerting-on-azure-automation-accounts/</link>
					<comments>https://www.techguy.at/mail-alerting-on-azure-automation-accounts/#comments</comments>
		
		<dc:creator><![CDATA[Michael Seidl]]></dc:creator>
		<pubDate>Mon, 23 Sep 2024 17:47:44 +0000</pubDate>
				<category><![CDATA[Azure Automation]]></category>
		<category><![CDATA[Alerting]]></category>
		<category><![CDATA[azure automation]]></category>
		<guid isPermaLink="false">https://www.techguy.at/?p=6202</guid>

					<description><![CDATA[<p>We are working heavily with Azure Automation for our customers and often need a simple Alert for errors happening in a runbook. Of course, there are plenty of Alerting Solutions where you can integrate Azure Automation. We often see that things don&#8217;t go well or that the Alerts are not monitored. When we do Azure [&#8230;]</p>
<p>The post <a href="https://www.techguy.at/mail-alerting-on-azure-automation-accounts/" data-wpel-link="internal">Mail Alerting on Azure Automation Accounts</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->

Releated Posts:<ol>
<li><a href="https://www.techguy.at/query-azure-sql-database-with-powershell-and-azure-app-registration/" rel="bookmark" title="Query Azure SQL Database with PowerShell and Azure App Registration" data-wpel-link="internal">Query Azure SQL Database with PowerShell and Azure App Registration</a> <small>As you already know, I love to use Azure App...</small></li>
<li><a href="https://www.techguy.at/control-azure-vm-with-powershell-and-azure-rest-api/" rel="bookmark" title="Control Azure VM with PowerShell and Azure REST API" data-wpel-link="internal">Control Azure VM with PowerShell and Azure REST API</a> <small>Today I want to show you how to control an...</small></li>
<li><a href="https://www.techguy.at/control-secrets-in-azure-app-reg-manage-azure-app-reg-with-powershell-and-msgraph-api-part-2/" rel="bookmark" title="Control Secrets in Azure App Reg &#8211; Manage Azure App Reg with PowerShell and MSGRAPH API &#8211; Part 2" data-wpel-link="internal">Control Secrets in Azure App Reg &#8211; Manage Azure App Reg with PowerShell and MSGRAPH API &#8211; Part 2</a> <small>This is the second part of this Blog Series on...</small></li>
<li><a href="https://www.techguy.at/create-and-delete-azure-app-regs-manage-azure-app-reg-with-powershell-and-msgraph-api-part-1/" rel="bookmark" title="Create and delete Azure App Regs &#8211; Manage Azure App Reg with PowerShell and MSGRAPH API &#8211; Part 1" data-wpel-link="internal">Create and delete Azure App Regs &#8211; Manage Azure App Reg with PowerShell and MSGRAPH API &#8211; Part 1</a> <small>In this Blog Post, I am trying to explain how...</small></li>
<li><a href="https://www.techguy.at/1-year-notion-or-how-au2mator-is-doing-internal-automation/" rel="bookmark" title="1-Year Notion, or how au2mator is doing internal automation." data-wpel-link="internal">1-Year Notion, or how au2mator is doing internal automation.</a> <small>This article could be more technical. It should show how...</small></li>
</ol>
</div>
]]></description>
										<content:encoded><![CDATA[
<p>We are working heavily with Azure Automation for our customers and often need a simple Alert for errors happening in a runbook. Of course, there are plenty of Alerting Solutions where you can integrate Azure Automation.</p>



<p>We often see that things don&#8217;t go well or that the Alerts are not monitored. When we do Azure Automation Consulting, we also take care of Alerts, so we use simple Mail Alerting in Azure.</p>



<p>Here I want to show how we are configuring this at our Customers.</p>



<p>Open portal.azure.com with appropriate Permissions to create an Alert Rule and create a Diagnostic Setting</p>



<p>Open your Azure Automation Account</p>



<p>Navigate to Monitoring/Diagnostic settings</p>



<p>and click &#8220;Add diagnostic setting.&#8221;</p>



<p>select &#8220;allLogs&#8221; and &#8220;AllMetrics&#8221;</p>



<p>Select &#8220;Send to Log Analytics workspace&#8221; and select or create a Log Analytics workspace.</p>



<p>Click &#8220;Save.&#8221;</p>



<p>Navigate to Monitoring/Alerts in the same Automation Account</p>



<p>Create a new &#8220;Alert Rule.&#8221;</p>



<p></p>



<p>On the &#8220;Condition&#8221; Tab, choose &#8220;Custom Log Search&#8221; from Signal name</p>



<p>Enter the following Query in the &#8220;Search Query&#8221;</p>



<pre class="wp-block-code"><code>// Find logs reporting errors in automation jobs from the last day 
// List all the errors in the automation jobs. 
// To create an alert for this query, click '+ New alert rule'
AzureDiagnostics 
| where ResourceProvider == "MICROSOFT.AUTOMATION" 
| where StreamType_s == "Error" 
| project TimeGenerated, Category, JobId_g, OperationName, RunbookName_s, ResultDescription, _ResourceId 

</code></pre>



<p>Choose the following Option at Measurement and Alert Logic</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1042" height="518" src="https://www.techguy.at/wp-content/uploads/2024/09/image-3.png" alt="" class="wp-image-6207" srcset="https://www.techguy.at/wp-content/uploads/2024/09/image-3.png 1042w, https://www.techguy.at/wp-content/uploads/2024/09/image-3-768x382.png 768w" sizes="auto, (max-width: 1042px) 100vw, 1042px" /></figure>



<p>At the &#8220;Actions&#8221; Tab, choose &#8220;Use quick actions&#8221; and configure your Mail Alert</p>



<p>At the &#8220;Details&#8221; Page, choose your preferred Alert Details</p>



<p>I would recommend choosing &#8220;1- Error&#8221; for Severity; the rest is up to you and your Environment</p>



<p>So, whenever an error happens in one of your Runbooks, you should receive an email</p>



<p>The Scenario</p>



<p>So, when you have a Runbook that shows the State &#8220;Completed&#8221; but throws an error inside with &#8220;Write-Error,&#8221; you usually will not be notified. It will not show up on the Main Logs Page.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1390" height="593" src="https://www.techguy.at/wp-content/uploads/2024/09/image-4.png" alt="" class="wp-image-6208" srcset="https://www.techguy.at/wp-content/uploads/2024/09/image-4.png 1390w, https://www.techguy.at/wp-content/uploads/2024/09/image-4-768x328.png 768w" sizes="auto, (max-width: 1390px) 100vw, 1390px" /></figure>



<p>So, with our solution, you will receive an Email like this</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1012" height="824" src="https://www.techguy.at/wp-content/uploads/2024/09/image-5.png" alt="" class="wp-image-6209" srcset="https://www.techguy.at/wp-content/uploads/2024/09/image-5.png 1012w, https://www.techguy.at/wp-content/uploads/2024/09/image-5-768x625.png 768w" sizes="auto, (max-width: 1012px) 100vw, 1012px" /></figure>



<p>By the click on &#8220;View query results,&#8221; you will see the triggered runbook that caused the Error</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1362" height="681" src="https://www.techguy.at/wp-content/uploads/2024/09/image-6.png" alt="" class="wp-image-6210" srcset="https://www.techguy.at/wp-content/uploads/2024/09/image-6.png 1362w, https://www.techguy.at/wp-content/uploads/2024/09/image-6-768x384.png 768w" sizes="auto, (max-width: 1362px) 100vw, 1362px" /></figure>



<p>So, no more excuses that Alerting it to complicates.</p>



<p>The cost of this will be around 1,50 Euro per Month.</p>



<p>Michael Seidl aka Techguy<br>#autoamtionmindset</p>



<p></p>



<p></p>



<p></p>



<p></p>
<p>The post <a href="https://www.techguy.at/mail-alerting-on-azure-automation-accounts/" data-wpel-link="internal">Mail Alerting on Azure Automation Accounts</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->
<p>Releated Posts:<ol>
<li><a href="https://www.techguy.at/query-azure-sql-database-with-powershell-and-azure-app-registration/" rel="bookmark" title="Query Azure SQL Database with PowerShell and Azure App Registration" data-wpel-link="internal">Query Azure SQL Database with PowerShell and Azure App Registration</a> <small>As you already know, I love to use Azure App...</small></li>
<li><a href="https://www.techguy.at/control-azure-vm-with-powershell-and-azure-rest-api/" rel="bookmark" title="Control Azure VM with PowerShell and Azure REST API" data-wpel-link="internal">Control Azure VM with PowerShell and Azure REST API</a> <small>Today I want to show you how to control an...</small></li>
<li><a href="https://www.techguy.at/control-secrets-in-azure-app-reg-manage-azure-app-reg-with-powershell-and-msgraph-api-part-2/" rel="bookmark" title="Control Secrets in Azure App Reg &#8211; Manage Azure App Reg with PowerShell and MSGRAPH API &#8211; Part 2" data-wpel-link="internal">Control Secrets in Azure App Reg &#8211; Manage Azure App Reg with PowerShell and MSGRAPH API &#8211; Part 2</a> <small>This is the second part of this Blog Series on...</small></li>
<li><a href="https://www.techguy.at/create-and-delete-azure-app-regs-manage-azure-app-reg-with-powershell-and-msgraph-api-part-1/" rel="bookmark" title="Create and delete Azure App Regs &#8211; Manage Azure App Reg with PowerShell and MSGRAPH API &#8211; Part 1" data-wpel-link="internal">Create and delete Azure App Regs &#8211; Manage Azure App Reg with PowerShell and MSGRAPH API &#8211; Part 1</a> <small>In this Blog Post, I am trying to explain how...</small></li>
<li><a href="https://www.techguy.at/1-year-notion-or-how-au2mator-is-doing-internal-automation/" rel="bookmark" title="1-Year Notion, or how au2mator is doing internal automation." data-wpel-link="internal">1-Year Notion, or how au2mator is doing internal automation.</a> <small>This article could be more technical. It should show how...</small></li>
</ol></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.techguy.at/mail-alerting-on-azure-automation-accounts/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">6202</post-id>	</item>
		<item>
		<title>Send a OneDrive File via Mail with MS GRAPH API and Powershell</title>
		<link>https://www.techguy.at/send-a-onedrive-file-via-mail-with-ms-graph-api-and-powershell/</link>
					<comments>https://www.techguy.at/send-a-onedrive-file-via-mail-with-ms-graph-api-and-powershell/#respond</comments>
		
		<dc:creator><![CDATA[Michael Seidl]]></dc:creator>
		<pubDate>Tue, 20 Feb 2024 13:27:10 +0000</pubDate>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[msgraphapi]]></category>
		<category><![CDATA[Onedrive]]></category>
		<category><![CDATA[Powershell]]></category>
		<guid isPermaLink="false">https://www.techguy.at/?p=6171</guid>

					<description><![CDATA[<p>Recently, I automated our invoice sending and automatically uploaded the file to OneDrive and sent it via mail. today, I want to show a snipped of this code on how to download a file from Onedrive and Send via Mail More Details here: DriveItem &#8211; OneDrive API &#8211; OneDrive dev center &#124; Microsoft Learn The [&#8230;]</p>
<p>The post <a href="https://www.techguy.at/send-a-onedrive-file-via-mail-with-ms-graph-api-and-powershell/" data-wpel-link="internal">Send a OneDrive File via Mail with MS GRAPH API and Powershell</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->

Releated Posts:<ol>
<li><a href="https://www.techguy.at/upload-a-file-to-onedrive-via-graph-api-and-powershell/" rel="bookmark" title="Upload a File to OneDrive via Graph API and PowerShell" data-wpel-link="internal">Upload a File to OneDrive via Graph API and PowerShell</a> <small>Recently, I upgraded my Invoicing automation, so I create Invoices...</small></li>
<li><a href="https://www.techguy.at/send-mail-with-attachment-powershell-and-microsoft-graph-api/" rel="bookmark" title="Send Mail with Attachment, PowerShell, and Microsoft Graph API" data-wpel-link="internal">Send Mail with Attachment, PowerShell, and Microsoft Graph API</a> <small>I received a huge response to my previous Article to...</small></li>
<li><a href="https://www.techguy.at/send-mail-with-powershell-and-microsoft-graph-api/" rel="bookmark" title="Send Mail with PowerShell and Microsoft Graph API" data-wpel-link="internal">Send Mail with PowerShell and Microsoft Graph API</a> <small>We all know that the Basic Authentication end is near...</small></li>
<li><a href="https://www.techguy.at/draft-mail-with-powershell-and-microsoft-graph-api/" rel="bookmark" title="Draft Mail with PowerShell and Microsoft Graph API" data-wpel-link="internal">Draft Mail with PowerShell and Microsoft Graph API</a> <small>Recently, I updated our internal Invoice automation and wanted to...</small></li>
<li><a href="https://www.techguy.at/send-chat-message-to-a-teams-channel-with-powershell-and-ms-graph-api/" rel="bookmark" title="Send Chat Message to a Teams Channel with PowerShell and MS GRAPH API" data-wpel-link="internal">Send Chat Message to a Teams Channel with PowerShell and MS GRAPH API</a> <small>The next Post in my GRAPH API Series now switches...</small></li>
</ol>
</div>
]]></description>
										<content:encoded><![CDATA[
<p>Recently, I automated our invoice sending and automatically uploaded the file to OneDrive and sent it via mail. today, I want to show a snipped of this code on  how to download a file from Onedrive and Send via Mail</p>



<ul class="wp-block-list">
<li>Application &#8211; OneDrive
<ul class="wp-block-list">
<li>Files.Read.All</li>



<li>Files.ReadWrite.All</li>



<li>Sites.Read.All</li>



<li>Sites.ReadWrite.All</li>
</ul>
</li>



<li>Application &#8211; Mail
<ul class="wp-block-list">
<li>Mail.Send</li>
</ul>
</li>
</ul>



<p>More Details here: <a href="https://learn.microsoft.com/en-us/onedrive/developer/rest-api/resources/driveitem?view=odsp-graph-online" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">DriveItem &#8211; OneDrive API &#8211; OneDrive dev center | Microsoft Learn</a></p>



<p></p>



<h2 class="wp-block-heading" id="h-the-script">The Script</h2>



<p>Here is the full Script with comments. Please remember that the scripts are maintained on GitHub, so I recommend navigating to the latest version of GitHub.</p>



<pre class="wp-block-code"><code>#OneDrive Detais
$OneDrive_User="michael.seidl@au2mator.com" #User UPN for OneDrive
$OneDrive_Path="0-Temp" # Full path in OneDrive from root, example "0-Temp/My Files/Folder1"
$OneDrive_FileName = "Hello World.pdf" #File Name to send in the Path from above


#Global GRAPH API Details
$tenantID = "your Tenant ID"
$GraphAPI_BaseURL="https://graph.microsoft.com/v1.0"



#OneDrive Graph API Details
$clientID_OneDrive = "Your Client ID for OneDrive"
$Clientsecret_OneDrive = "your Scret"

#Mail Graph API Details
$clientID_Mail = "your Client ID for Mail"
$Clientsecret_Mail = "your Secret"



#Mail Details
$MailSender="michael.seidl@au2mator.com"
$Recipient="michael.seidl@au2mator.com"

#Graph API Authentication
$tokenBody = @{
    Grant_Type    = "client_credentials"
    Scope         = "https://graph.microsoft.com/.default"
    Client_Id     = $clientID_OneDrive
    Client_Secret = $Clientsecret_OneDrive
}
$tokenResponse = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$tenantID/oauth2/v2.0/token" -Method POST -Body $tokenBody
$headers_OneDrive = @{
    "Authorization" = "Bearer $($tokenResponse.access_token)"
    "Content-type"  = "application/json"
}



#Define temp File Donwload Path
$Out = "$env:TEMP\$OneDrive_FileName" 

#Get File from OneDrive
#Get the Drive for the next step
$Drive = Invoke-RestMethod -Uri "$GraphAPI_BaseURL/users/$OneDrive_User/drive" -Method GET -Headers $headers_OneDrive

#Get all Child Elements from your folder
$DestFolder = Invoke-RestMethod -Uri "https://graph.microsoft.com/v1.0/users/michael.seidl@au2mator.com/drives/$($Drive.id)/root:/$($OneDrive_Path):/children" -Method GET -Headers $headers_OneDrive 

#Query your file
$FileQuery=$DestFolder.value | Where-Object -Property name -Value "$OneDrive_FileName" -eq

#Download your File
Invoke-RestMethod -Uri "https://graph.microsoft.com/v1.0/users/michael.seidl@au2mator.com/drives/$($Drive.id)/items/$($FileQuery.id)/content" -Method GET -Headers $headers_OneDrive -OutFile $Out


  
#Convert File to Base64
$base64string = &#91;Convert]::ToBase64String(&#91;IO.File]::ReadAllBytes($Out))



#Send Mail
#Connect to GRAPH API
$tokenBody = @{
    Grant_Type    = "client_credentials"
    Scope         = "https://graph.microsoft.com/.default"
    Client_Id     = $clientID_Mail
    Client_Secret = $Clientsecret_Mail
}
$tokenResponse = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$tenantID/oauth2/v2.0/token" -Method POST -Body $tokenBody
$headers_Mail = @{
    "Authorization" = "Bearer $($tokenResponse.access_token)"
    "Content-type"  = "application/json"
}





#Send Mail
$URLsend = "https://graph.microsoft.com/v1.0/users/$MailSender/sendMail"
$BodyJsonsend = @"
                    {
                        "message": {
                          "subject": "au2mator $InvoiceNumber",
                          "body": {
                            "contentType": "HTML",
                            "content": "$MailText
                            "
                          },
                          
                          "toRecipients": &#91;
                            {
                              "emailAddress": {
                                "address": "$Recipient"
                              }
                            }
                          ]
                          ,"attachments": &#91;
                            {
                              "@odata.type": "#microsoft.graph.fileAttachment",
                              "name": "$($OneDrive_FileName)",
                              "contentType": "text/plain",
                              "contentBytes": "$base64string "
                            }
                          ]
                        },
                        "saveToSentItems": "true"
                      }
"@



Invoke-RestMethod -Method POST -Uri $URLsend -Headers $headers_Mail -Body $BodyJsonsend  -ContentType "application/json; charset=utf-8"

</code></pre>



<h2 class="wp-block-heading" id="h-the-result"></h2>



<h2 class="wp-block-heading" id="h-github">Github</h2>



<p>Make sure to get the latest version from GitHub:<a href="https://github.com/Seidlm/Microsoft-Teams" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external"> <a href="https://github.com/Seidlm/Microsoft-Graph-API-Examples" target="_blank" rel="noopener">Seidlm/Microsoft-Graph-API-Examples (github.com)</a></a> (Send OneDrive File via Mail.ps1)</p>



<p>Michael Seidl aka Techguy<br>au2mate everything<br>#AutomationMindset<br></p>
<p>The post <a href="https://www.techguy.at/send-a-onedrive-file-via-mail-with-ms-graph-api-and-powershell/" data-wpel-link="internal">Send a OneDrive File via Mail with MS GRAPH API and Powershell</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->
<p>Releated Posts:<ol>
<li><a href="https://www.techguy.at/upload-a-file-to-onedrive-via-graph-api-and-powershell/" rel="bookmark" title="Upload a File to OneDrive via Graph API and PowerShell" data-wpel-link="internal">Upload a File to OneDrive via Graph API and PowerShell</a> <small>Recently, I upgraded my Invoicing automation, so I create Invoices...</small></li>
<li><a href="https://www.techguy.at/send-mail-with-attachment-powershell-and-microsoft-graph-api/" rel="bookmark" title="Send Mail with Attachment, PowerShell, and Microsoft Graph API" data-wpel-link="internal">Send Mail with Attachment, PowerShell, and Microsoft Graph API</a> <small>I received a huge response to my previous Article to...</small></li>
<li><a href="https://www.techguy.at/send-mail-with-powershell-and-microsoft-graph-api/" rel="bookmark" title="Send Mail with PowerShell and Microsoft Graph API" data-wpel-link="internal">Send Mail with PowerShell and Microsoft Graph API</a> <small>We all know that the Basic Authentication end is near...</small></li>
<li><a href="https://www.techguy.at/draft-mail-with-powershell-and-microsoft-graph-api/" rel="bookmark" title="Draft Mail with PowerShell and Microsoft Graph API" data-wpel-link="internal">Draft Mail with PowerShell and Microsoft Graph API</a> <small>Recently, I updated our internal Invoice automation and wanted to...</small></li>
<li><a href="https://www.techguy.at/send-chat-message-to-a-teams-channel-with-powershell-and-ms-graph-api/" rel="bookmark" title="Send Chat Message to a Teams Channel with PowerShell and MS GRAPH API" data-wpel-link="internal">Send Chat Message to a Teams Channel with PowerShell and MS GRAPH API</a> <small>The next Post in my GRAPH API Series now switches...</small></li>
</ol></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.techguy.at/send-a-onedrive-file-via-mail-with-ms-graph-api-and-powershell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">6171</post-id>	</item>
		<item>
		<title>Create a Teams Appointment with MS GRAPH API and Powershell</title>
		<link>https://www.techguy.at/create-a-teams-appointment-with-ms-graph-api-and-powershell/</link>
					<comments>https://www.techguy.at/create-a-teams-appointment-with-ms-graph-api-and-powershell/#respond</comments>
		
		<dc:creator><![CDATA[Michael Seidl]]></dc:creator>
		<pubDate>Tue, 20 Feb 2024 13:11:04 +0000</pubDate>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[msgraphapi]]></category>
		<category><![CDATA[Powershell]]></category>
		<guid isPermaLink="false">https://www.techguy.at/?p=6166</guid>

					<description><![CDATA[<p>Recently, I created an Azure Automation Runbook to keep my Notions Tasks in Sync with my Calendar. I used Graph API to create and update my Outlook Events. From this, I also tried to send a Teams Appointment Invite with Powershell and Graph API. The result is below. More Details here: Create event &#8211; Microsoft [&#8230;]</p>
<p>The post <a href="https://www.techguy.at/create-a-teams-appointment-with-ms-graph-api-and-powershell/" data-wpel-link="internal">Create a Teams Appointment with MS GRAPH API and Powershell</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->

Releated Posts:<ol>
<li><a href="https://www.techguy.at/create-an-outlook-appointment-with-ms-graph-api-and-powershell/" rel="bookmark" title="Create an Outlook Appointment with MS GRAPH API and Powershell" data-wpel-link="internal">Create an Outlook Appointment with MS GRAPH API and Powershell</a> <small>Recently, I created an Azure Automation Runbook to keep my...</small></li>
<li><a href="https://www.techguy.at/create-a-channel-in-teams-with-powershell-and-ms-graph-api/" rel="bookmark" title="Create a Channel in Teams with PowerShell and MS Graph API" data-wpel-link="internal">Create a Channel in Teams with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
<li><a href="https://www.techguy.at/create-azure-guest-user-with-powershell-and-ms-graph-api/" rel="bookmark" title="Create Azure Guest User with PowerShell and MS Graph API" data-wpel-link="internal">Create Azure Guest User with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
<li><a href="https://www.techguy.at/add-a-member-to-a-microsoft-teams-team-with-powershell-and-ms-graph-api/" rel="bookmark" title="Add a Member to a Microsoft Teams Team with PowerShell and MS Graph API" data-wpel-link="internal">Add a Member to a Microsoft Teams Team with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
<li><a href="https://www.techguy.at/change-a-teams-owner-to-a-member-with-powershell-and-ms-graph-api/" rel="bookmark" title="Change a Teams Owner to a Member with PowerShell and MS Graph API" data-wpel-link="internal">Change a Teams Owner to a Member with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
</ol>
</div>
]]></description>
										<content:encoded><![CDATA[
<p>Recently, I created an Azure Automation Runbook to keep my Notions Tasks in Sync with my Calendar. I used Graph API to create and update my Outlook Events.</p>



<p>From this, I also tried to send a Teams Appointment Invite with Powershell and Graph API. The result is below.</p>



<ul class="wp-block-list">
<li>Application
<ul class="wp-block-list">
<li>Calendars.ReadWrite</li>
</ul>
</li>
</ul>



<p>More Details here: <a href="https://learn.microsoft.com/en-us/graph/api/user-post-events?view=graph-rest-1.0&amp;tabs=http" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">Create event &#8211; Microsoft Graph v1.0 | Microsoft Learn</a></p>



<p></p>



<h2 class="wp-block-heading" id="h-the-script">The Script</h2>



<p>Here is the full Script with comments. Please remember that the scripts are maintained on GitHub, so I recommend navigating to the latest version of GitHub.</p>



<pre class="wp-block-code"><code>$clientID = "your ClientID"
$Clientsecret = "Your Secret"
$tenantID = "your TenantID"

$Graph_BaseURL = "https://graph.microsoft.com/v1.0"


#Calendar User
$TargetUser="michael.seidl@au2mator.com"


#Invite User
$RecipientMail="ahmed.uzejnovic@au2mator.com"
$RecipientName="Ahmed Uzejnovic"
$RecipientType="required" #required, optional



#Teams Event Details
$TeamsEventSubject = "My Teams-GRAPH API Event"
$TeamsEventBody = "Thats my awesome Teams-GRAPH API Event Body"

$TeamsEventStart = "2024-02-25T09:00:00"
$TeamsEventEnd = "2024-02-25T10:00:00"
$timeZone = "UTC"



#Authentication
#Connect to GRAPH API
$tokenBody = @{
    Grant_Type    = "client_credentials"
    Scope         = "https://graph.microsoft.com/.default"
    Client_Id     = $clientId
    Client_Secret = $clientSecret
}
$tokenResponse = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$tenantID/oauth2/v2.0/token" -Method POST -Body $tokenBody
$headers = @{
    "Authorization" = "Bearer $($tokenResponse.access_token)"
    "Content-type"  = "application/json"
}



$TeamsEventJson = @"
{
  "subject": "$TeamsEventSubject",
  "isOnlineMeeting": true,
  "onlineMeetingProvider": "teamsForBusiness",
  "attendees": &#91;
    {
      "emailAddress": {
        "address":"$RecipientMail",
        "name": "$RecipientName"
      },
      "type": "$RecipientType"
    }
  ],
  "body": {
    "contentType": "HTML",
    "content": "$($TeamsEventBody)"
  },
  "start": {
      "dateTime": "$($TeamsEventStart)",
      "timeZone": "$timeZone"
  },
  "end": {
      "dateTime": "$($TeamsEventEnd)",
      "timeZone": "$timeZone"
  }
}
"@


$TeamsEvent = Invoke-RestMethod -Uri "$Graph_BaseURL/users/$TargetUser/calendar/events" -Method POST -Headers $headers -Body $TeamsEventJson -ContentType "application/json; charset=utf-8"
</code></pre>



<h2 class="wp-block-heading" id="h-the-result">The Result</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="932" height="898" src="https://www.techguy.at/wp-content/uploads/2024/02/2024-02-20-13_56_00-My-Teams-GRAPH-API-Event-Meeting-1.png" alt="" class="wp-image-6168" srcset="https://www.techguy.at/wp-content/uploads/2024/02/2024-02-20-13_56_00-My-Teams-GRAPH-API-Event-Meeting-1.png 932w, https://www.techguy.at/wp-content/uploads/2024/02/2024-02-20-13_56_00-My-Teams-GRAPH-API-Event-Meeting-1-768x740.png 768w" sizes="auto, (max-width: 932px) 100vw, 932px" /></figure>



<p></p>



<h2 class="wp-block-heading" id="h-github">Github</h2>



<p>Make sure to get the latest version from GitHub: <a href="https://github.com/Seidlm/Microsoft-Teams" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external"><a href="https://github.com/Seidlm/Microsoft-Teams" target="_blank" rel="noopener">Seidlm/Microsoft-Teams (github.com)</a></a> (New Teams Invite.ps1)</p>



<p>Michael Seidl aka Techguy<br>au2mate everything<br>#AutomationMindset<br></p>
<p>The post <a href="https://www.techguy.at/create-a-teams-appointment-with-ms-graph-api-and-powershell/" data-wpel-link="internal">Create a Teams Appointment with MS GRAPH API and Powershell</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->
<p>Releated Posts:<ol>
<li><a href="https://www.techguy.at/create-an-outlook-appointment-with-ms-graph-api-and-powershell/" rel="bookmark" title="Create an Outlook Appointment with MS GRAPH API and Powershell" data-wpel-link="internal">Create an Outlook Appointment with MS GRAPH API and Powershell</a> <small>Recently, I created an Azure Automation Runbook to keep my...</small></li>
<li><a href="https://www.techguy.at/create-a-channel-in-teams-with-powershell-and-ms-graph-api/" rel="bookmark" title="Create a Channel in Teams with PowerShell and MS Graph API" data-wpel-link="internal">Create a Channel in Teams with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
<li><a href="https://www.techguy.at/create-azure-guest-user-with-powershell-and-ms-graph-api/" rel="bookmark" title="Create Azure Guest User with PowerShell and MS Graph API" data-wpel-link="internal">Create Azure Guest User with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
<li><a href="https://www.techguy.at/add-a-member-to-a-microsoft-teams-team-with-powershell-and-ms-graph-api/" rel="bookmark" title="Add a Member to a Microsoft Teams Team with PowerShell and MS Graph API" data-wpel-link="internal">Add a Member to a Microsoft Teams Team with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
<li><a href="https://www.techguy.at/change-a-teams-owner-to-a-member-with-powershell-and-ms-graph-api/" rel="bookmark" title="Change a Teams Owner to a Member with PowerShell and MS Graph API" data-wpel-link="internal">Change a Teams Owner to a Member with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
</ol></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.techguy.at/create-a-teams-appointment-with-ms-graph-api-and-powershell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">6166</post-id>	</item>
		<item>
		<title>Create an Outlook Appointment with MS GRAPH API and Powershell</title>
		<link>https://www.techguy.at/create-an-outlook-appointment-with-ms-graph-api-and-powershell/</link>
					<comments>https://www.techguy.at/create-an-outlook-appointment-with-ms-graph-api-and-powershell/#respond</comments>
		
		<dc:creator><![CDATA[Michael Seidl]]></dc:creator>
		<pubDate>Thu, 01 Feb 2024 13:53:46 +0000</pubDate>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[msgraphapi]]></category>
		<category><![CDATA[Powershell]]></category>
		<guid isPermaLink="false">https://www.techguy.at/?p=6152</guid>

					<description><![CDATA[<p>Recently, I created an Azure Automation Runbook to keep my Notions Tasks in Sync with my Calendar. I used Graph API to create and update my Outlook Events. So, we need Powershell and the Following GRAPH API Permission for our Script. More Details here: Create event &#8211; Microsoft Graph v1.0 &#124; Microsoft Learn The Script [&#8230;]</p>
<p>The post <a href="https://www.techguy.at/create-an-outlook-appointment-with-ms-graph-api-and-powershell/" data-wpel-link="internal">Create an Outlook Appointment with MS GRAPH API and Powershell</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->

Releated Posts:<ol>
<li><a href="https://www.techguy.at/create-microsoft-todo-task-with-powershell-and-microsoft-graph-api/" rel="bookmark" title="Create Microsoft ToDo Task with PowerShell and Microsoft GRAPH API" data-wpel-link="internal">Create Microsoft ToDo Task with PowerShell and Microsoft GRAPH API</a> <small>Now it is time to create some Microsoft ToDo Tasks...</small></li>
<li><a href="https://www.techguy.at/create-microsoft-team-with-powershell-and-ms-graph-api/" rel="bookmark" title="Create Microsoft Team with PowerShell and MS Graph API" data-wpel-link="internal">Create Microsoft Team with PowerShell and MS Graph API</a> <small>The next Post in my GRAPH API Series now switches...</small></li>
<li><a href="https://www.techguy.at/create-azure-guest-user-with-powershell-and-ms-graph-api/" rel="bookmark" title="Create Azure Guest User with PowerShell and MS Graph API" data-wpel-link="internal">Create Azure Guest User with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
<li><a href="https://www.techguy.at/create-azure-resource-group-with-powershell-and-ms-graph-api/" rel="bookmark" title="Create Azure Resource Group with PowerShell and MS Graph API" data-wpel-link="internal">Create Azure Resource Group with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
<li><a href="https://www.techguy.at/create-a-channel-in-teams-with-powershell-and-ms-graph-api/" rel="bookmark" title="Create a Channel in Teams with PowerShell and MS Graph API" data-wpel-link="internal">Create a Channel in Teams with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
</ol>
</div>
]]></description>
										<content:encoded><![CDATA[
<p>Recently, I created an Azure Automation Runbook to keep my Notions Tasks in Sync with my Calendar. I used Graph API to create and update my Outlook Events.</p>



<p>So, we need Powershell and the Following GRAPH API Permission for our Script.</p>



<ul class="wp-block-list">
<li>Application
<ul class="wp-block-list">
<li>Calendars.ReadWrite</li>
</ul>
</li>
</ul>



<p>More Details here: <a href="https://learn.microsoft.com/en-us/graph/api/user-post-events?view=graph-rest-1.0&amp;tabs=http" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">Create event &#8211; Microsoft Graph v1.0 | Microsoft Learn</a></p>



<p></p>



<h2 class="wp-block-heading" id="h-the-script">The Script</h2>



<p>Here is the full Script with comments. Please remember that the scripts are maintained on GitHub, so I recommend navigating to the latest version of GitHub.</p>



<pre class="wp-block-code"><code>$clientID = "your Client ID"
$Clientsecret = "your Secret"
$tenantID = "your Tenant ID"

$Graph_BaseURL = "https://graph.microsoft.com/v1.0"


#Calendar User
$TargetUser="michael.seidl@au2mator.com"


#Simple Event Details
$EventSubject = "My GRAPH API Event"
$EventBody = "Thats my awesome GRAPH API Event Body"
$EventLocation = "Microsoft Headquarter"

$EventStart = "2024-02-10T09:00:00"
$EventEnd = "2024-02-10T10:00:00"
$timeZone = "UTC"


#Authentication
#Connect to GRAPH API
$tokenBody = @{
    Grant_Type    = "client_credentials"
    Scope         = "https://graph.microsoft.com/.default"
    Client_Id     = $clientId
    Client_Secret = $clientSecret
}
$tokenResponse = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$tenantID/oauth2/v2.0/token" -Method POST -Body $tokenBody
$headers = @{
    "Authorization" = "Bearer $($tokenResponse.access_token)"
    "Content-type"  = "application/json"
}



$SimpleEventJson = @"
{
  "subject": "$EventSubject",
  "location":{
    "displayName":"$EventLocation",
    "address":{
        "street":"4567 Main St",
        "city":"Redmond",
        "state":"WA",
        "countryOrRegion":"US",
        "postalCode":"32008"
      },
},
  "body": {
    "contentType": "HTML",
    "content": "$($EventBody)"
  },
  "start": {
      "dateTime": "$($EventStart)",
      "timeZone": "$timeZone"
  },
  "end": {
      "dateTime": "$($EventEnd)",
      "timeZone": "$timeZone"
  }
}
"@

$SimpleEvent = Invoke-RestMethod -Uri "$Graph_BaseURL/users/$TargetUser/calendar/events" -Method POST -Headers $headers -Body $simpleEventJson -ContentType "application/json; charset=utf-8"


</code></pre>



<h2 class="wp-block-heading" id="h-the-result">The Result</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="926" height="268" src="https://www.techguy.at/wp-content/uploads/2024/02/image.png" alt="" class="wp-image-6153" srcset="https://www.techguy.at/wp-content/uploads/2024/02/image.png 926w, https://www.techguy.at/wp-content/uploads/2024/02/image-768x222.png 768w" sizes="auto, (max-width: 926px) 100vw, 926px" /></figure>



<p></p>



<h2 class="wp-block-heading" id="h-github">Github</h2>



<p>Make sure to get the latest version from GitHub: <a href="https://github.com/Seidlm/Microsoft-Graph-API-Examples" target="_blank" rel="noopener follow noreferrer" data-wpel-link="external">Seidlm/Microsoft-Graph-API-Examples (github.com)</a> (New Outlook Appointment.ps1)</p>



<p>Michael Seidl aka Techguy<br>au2mate everything<br>#AutomationMindset<br></p>
<p>The post <a href="https://www.techguy.at/create-an-outlook-appointment-with-ms-graph-api-and-powershell/" data-wpel-link="internal">Create an Outlook Appointment with MS GRAPH API and Powershell</a> appeared first on <a href="https://www.techguy.at" data-wpel-link="internal">TechGuy</a>.</p>
<div class='yarpp yarpp-related yarpp-related-rss yarpp-template-list'>
<!-- YARPP List -->
<p>Releated Posts:<ol>
<li><a href="https://www.techguy.at/create-microsoft-todo-task-with-powershell-and-microsoft-graph-api/" rel="bookmark" title="Create Microsoft ToDo Task with PowerShell and Microsoft GRAPH API" data-wpel-link="internal">Create Microsoft ToDo Task with PowerShell and Microsoft GRAPH API</a> <small>Now it is time to create some Microsoft ToDo Tasks...</small></li>
<li><a href="https://www.techguy.at/create-microsoft-team-with-powershell-and-ms-graph-api/" rel="bookmark" title="Create Microsoft Team with PowerShell and MS Graph API" data-wpel-link="internal">Create Microsoft Team with PowerShell and MS Graph API</a> <small>The next Post in my GRAPH API Series now switches...</small></li>
<li><a href="https://www.techguy.at/create-azure-guest-user-with-powershell-and-ms-graph-api/" rel="bookmark" title="Create Azure Guest User with PowerShell and MS Graph API" data-wpel-link="internal">Create Azure Guest User with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
<li><a href="https://www.techguy.at/create-azure-resource-group-with-powershell-and-ms-graph-api/" rel="bookmark" title="Create Azure Resource Group with PowerShell and MS Graph API" data-wpel-link="internal">Create Azure Resource Group with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
<li><a href="https://www.techguy.at/create-a-channel-in-teams-with-powershell-and-ms-graph-api/" rel="bookmark" title="Create a Channel in Teams with PowerShell and MS Graph API" data-wpel-link="internal">Create a Channel in Teams with PowerShell and MS Graph API</a> <small>In this post, I want to show you how you...</small></li>
</ol></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.techguy.at/create-an-outlook-appointment-with-ms-graph-api-and-powershell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">6152</post-id>	</item>
	</channel>
</rss>
