Skip to content

Commit

Permalink
Commit from GitHub Actions (Generate Site)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkbullock committed Oct 7, 2024
1 parent b3b5fa0 commit 7f15b4f
Show file tree
Hide file tree
Showing 10 changed files with 7,776 additions and 7,385 deletions.
214 changes: 214 additions & 0 deletions aad-inactive-guest-delete/README.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html lang="en">

<head>
<meta charset="utf-8">
<title>Delete inactive Guest User | PnP Samples </title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" "="">
<meta name="title" content="Delete inactive Guest User | PnP Samples ">
<meta name="generator" content="docfx 2.56.7.0">
<meta name="description" content="A sample gallery of scripts to manage all things Microsoft 365.">

<!-- Social Media -->
<meta property="og:locale" content="en_GB">
<meta property="og:title" content="Delete inactive Guest User | PnP Samples ">
<meta property="og:type" content="website">
<meta property="og:url" content="https://pnp.github.io/script-samples">
<meta property="og:image" content="https://pnp.github.io/script-samples/assets/social-media-screenshot.png">
<meta property="og:image:alt" content="Screenshot example of the PnP Script Samples Site">
<meta property="og:site_name" content="PnP Script Samples">
<meta name="msvalidate.01" content="04EFEDA66EC42C08A1247C979E2F9ADD">
<meta property="og:description" content="A sample gallery of scripts to manage all things Microsoft 365.">

<link rel="shortcut icon" href="https://c.s-microsoft.com/favicon.ico?v2">
<link rel="stylesheet" href="../styles/docfx.vendor.css">
<link rel="stylesheet" href="../styles/docfx.css">
<link rel="stylesheet" href="../styles/main.css">
<link rel="stylesheet" href="../styles/extra.css">
<link rel="stylesheet" href="../styles/filter.css">
<link rel="stylesheet" href="../styles/site.css">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<meta property="docfx:navrel" content="../toc.html">
<meta property="docfx:tocrel" content="../toc.html">


<meta property="docfx:newtab" content="true">
<script type="text/javascript">
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "8j6pedl344");
</script>
</head> <body data-spy="scroll" data-target="#affix" data-offset="120">
<div id="wrapper">
<header>

<nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
<div class="container">
<div class="github-mark">
<a href="https://github.com/pnp/script-samples" title="Go to repository">
<div class="github-wrapper">
<div class="github-icon">
<img src="https://pnp.github.io/script-samples/assets/icons/github-light-64px.png" alt="GitHub Icon Image">
</div>
<div class="github-repository">
<span>GitHub</span>
<ul class="github-facts">
<li>
<i class="fa fa-code-fork" aria-hidden="true"></i>
<span class="github-forks"></span>
</li>
<li>
<i class="fa fa-star-o" aria-hidden="true"></i>
<span class="github-stars"></span>
</li>
</ul>
</div>
</div>
</a>
</div>
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../index.html">
<img id="logo" class="svg" src="../assets/logo.svg" alt="">
</a> </div>
<div class="collapse navbar-collapse" id="navbar">
<form class="navbar-form navbar-right" role="search" id="search">
<div class="form-group">
<label class="glyphicon glyphicon-search" for="search-query"></label>
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
</div>
</form>
</div>
</div>
</nav> </header>
<div role="main" class="container body-content hide-when-search">
<div class="article row grid">
<div class="col-md-12">
<article class="content wrap" id="_content" data-uid="">
<div class="contribution-panel mobile-hide pull-right">
<a href="https://github.com/pnp/script-samples/blob/main/scripts/aad-inactive-guest-delete/README.md/#L1" title="Improve this Doc" class="improve-doc-lg"><i class="glyphicon glyphicon-pencil"></i></a>
</div>
<h1 id="delete-inactive-guest-user">Delete inactive Guest User</h1>

<p>The script will report inactive users for x days and provides an option to delete them.</p>
<h2 id="summary">Summary</h2>
<p>This PowerShell script identifies and optionally deletes inactive guest users in Microsoft 365. It connects to Microsoft Graph, retrieves guest users, checks their last sign-in date, and lists those who have been inactive for a specified number of days. The script then prompts the user to confirm whether to delete these inactive users.</p>
<ul>
<li>Open Windows PowerShell ISE or VS Code</li>
<li>Copy script below to your clipboard</li>
<li>Modify the $daysInactive variable as needed.</li>
<li>Run the script to identify and optionally delete inactive guest users.</li>
</ul>
<div class="WARNING">
<h5>Warning</h5>
<p>Please be aware this script contains a command that will remove or delete an artifact, ensure you test and understand the implications of running the script.</p>
</div>
<div class="tabGroup" id="tabgroup_CeZOj-G++Q">
<ul role="tablist">
<li role="presentation">
<a href="#tabpanel_CeZOj-G++Q_graphps" role="tab" aria-controls="tabpanel_CeZOj-G++Q_graphps" data-tab="graphps" tabindex="0" aria-selected="true">Microsoft Graph PowerShell</a>
</li>
</ul>
<section id="tabpanel_CeZOj-G++Q_graphps" role="tabpanel" data-tab="graphps"><button class="article-clipboard" title="Copy to clipboard" data-toggle="tooltip" data-placement="top" data-clipboard-target="section[id^='tabpanel'][data-tab='graphps'] pre">
<span class="glyphicon glyphicon-copy" aria-hidden="true"></span>
<span class="article-clipboard__message done">Copied</span>
</button>

<pre><code class="lang-powershell">#Install-Module Microsoft.Graph
# Define the number of days of inactivity
$daysInactive = 30

Connect-MgGraph -Scopes &quot;User.Read.All&quot;, &quot;User.ReadWrite.All&quot;,&quot;AuditLog.Read.All&quot;

$calcDate = (Get-Date).AddDays($daysInactive * -1)

$guestUsers = Get-MgUser -Filter &quot;userType eq 'Guest'&quot; -All -Property id,displayName,mail,signInActivity,UserPrincipalName

$inactiveUsers = @()

foreach ($user in $guestUsers) {
if ($user.SignInActivity.LastSignInDateTime -ge $calcDate) {
$inactiveUsers += $user
}
}

if ($inactiveUsers.Count -gt 0) {
Write-Host &quot;The following guest users have been inactive for $daysInactive days or more:&quot;
$inactiveUsers | ForEach-Object {
Write-Host &quot;$($_.DisplayName) ($($_.UserPrincipalName))&quot;
}

# Ask if the user wants to delete the inactive users
$delete = Read-Host &quot;Do you want to delete these users? (y/n)&quot;
if ($delete -eq 'y') {
$inactiveUsers | ForEach-Object {
Remove-MgUser -UserId $_.Id -Confirm:$false
Write-Host &quot;Deleted user: $($_.DisplayName) ($($_.UserPrincipalName))&quot;
}
}
} else {
Write-Host &quot;No inactive guest users found.&quot;
}


Disconnect-MgGraph
</code></pre>
<div class="highlight-tool">
<p>Check out the <strong>Microsoft Graph PowerShell SDK</strong> to learn more at: <a href="https://learn.microsoft.com/graph/powershell/get-started">https://learn.microsoft.com/graph/powershell/get-started</a></p>
</div>
</section>
</div>
<h2 id="contributors">Contributors</h2>
<table>
<thead>
<tr>
<th>Author(s)</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://github.com/petkir">Peter Paul Kirschner</a></td>
</tr>
</tbody>
</table>
<h2 id="disclaimer">Disclaimer</h2>
<p><strong>THESE SAMPLES ARE PROVIDED <em>AS IS</em> WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.</strong></p>
<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/aad-inactive-guest-delete" aria-hidden="true">
</article>
</div>
</div>
</div>

<footer>
<div class="grad-bottom"></div>
<div class="footer">
<div class="container">
<span class="pull-right">
<a href="#top">Back to top</a>
</span>
<span>Script Samples<br>Generated by <strong><a href='https://dotnet.github.io/docfx' alt='Doc FX Website'>DocFX</a></strong> with <strong><a href='https://ovasquez.github.io/docfx-material' alt='DocFx Material Theme'>Material UI</a></strong></span>

<!-- <img src="https://telemetry.sharepointpnp.com/@pnp.github.io/index/" alt="spacer"> -->
</div>
</div>
</footer> </div>

<script type="text/javascript" src="../styles/docfx.vendor.js"></script>
<script type="text/javascript" src="../styles/docfx.js"></script>
<script type="text/javascript" src="../styles/main.js"></script>

<script type="text/javascript" src="../styles/clipboard.min.js"></script>
<script type="text/javascript" src="../styles/isotope.pkgd.min.js"></script>
<script type="text/javascript" src="../styles/loadsamples.js"></script>
<script type="text/javascript" src="../styles/filtersamples.js"></script>

</body>
</html>
Binary file added aad-inactive-guest-delete/assets/example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added aad-inactive-guest-delete/assets/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions aad-inactive-guest-delete/assets/sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[
{
"name": "aad-inactive-guest-delete",
"source": "pnp",
"title": "Delete inactive Guest User",
"shortDescription": "The script will report inactive users for x days and provides an option to delete them.",
"url": "https://pnp.github.io/script-samples/aad-inactive-guest-delete/README.html",
"longDescription": [
""
],
"creationDateTime": "2024-10-02",
"updateDateTime": "2024-10-02",
"products": [
"Graph"
],
"metadata": [
{
"key": "GRAPH-POWERSHELL",
"value": "1.0.0"
},
{
"key": "POWERSHELL",
"value": "7.2.0"
}
],
"categories": [
"Security"
],
"tags": [
"Get-MgUser",
"Remove-MgUser"
],
"thumbnails": [
{
"type": "image",
"order": 100,
"url": "https://raw.githubusercontent.com/pnp/script-samples/main/scripts/aad-inactive-guest-delete/assets/preview.png",
"alt": "Preview of the sample Delete inactive Guest User"
}
],
"authors": [
{
"gitHubAccount": "petkir",
"company": "ACP CUBIDO Digital Solutions GmbH",
"pictureUrl": "https://github.com/petkir.png",
"name": "Peter Paul Kirschner"
}
],
"references": [
{
"name": "Want to learn more about Microsoft Graph PowerShell SDK and the cmdlets",
"description": "Check out the Microsoft Graph PowerShell SDK documentation site to get started and for the reference to the cmdlets.",
"url": "https://learn.microsoft.com/graph/powershell/get-started"
}
]
}
]
7 changes: 6 additions & 1 deletion cmdusage.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ <h1 id="report-of-samples-command-usage">Report of Samples Command Usage</h1>
<td style="text-align: center;">Sign-In, Invoke-RestMethod, Start-Transcript, ConvertFrom-Json, Write-Host, read-host, Stop-Transcript, Test-GuestUserManagementList, New-GuestUserManagementList, Write-Verbose, Out-Null, Write-Error, Add-GuestUserManagementListItem, Get-JoinedTeams, Select-Object, Get-GuestUserSignInActivity, ForEach-Object, Add-Member</td>
</tr>
<tr>
<td><a href="aad-inactive-guest-delete/README.html">Delete inactive Guest User</a></td>
<td style="text-align: center;">Connect-MgGraph</td>
<td style="text-align: center;">sign-in, Get-MgUser, Write-Host, ForEach-Object, Read-Host, Remove-MgUser, Disconnect-MgGraph</td>
</tr>
<tr>
<td><a href="aad-replace-membership-of-selected-groups/README.html">Replace a user's membership in selected Microsoft 365 Groups or Teams</a></td>
<td style="text-align: center;">Add-PnPMicrosoft365GroupMember, Add-PnPMicrosoft365GroupOwner, Connect-PnPOnline, Get-PnPMicrosoft365Group, Get-PnPMicrosoft365GroupMember, Get-PnPMicrosoft365GroupOwner, Remove-PnPMicrosoft365Group, Remove-PnPMicrosoft365GroupMember, Remove-PnPMicrosoft365GroupOwner</td>
<td style="text-align: center;">Replace-Membership, Import-Csv, ForEach-Object, Write-Host, Where-Object</td>
Expand Down Expand Up @@ -1647,7 +1652,7 @@ <h3 id="sharepoint-online-management-shell-usage">SharePoint Online Management S
</tr>
</tbody>
</table>
<p>There are <strong>289</strong> script scenarios with metadata in the site | Generated: 07 Oct 2024 05:17:51</p>
<p>There are <strong>290</strong> script scenarios with metadata in the site | Generated: 07 Oct 2024 05:25:21</p>
</article>
</div>
</div>
Expand Down
52 changes: 49 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,52 @@
"is_incremental": false,
"version": ""
},
{
"type": "Conceptual",
"source_relative_path": "../scripts/aad-inactive-guest-delete/README.md",
"output": {
".html": {
"relative_path": "aad-inactive-guest-delete/README.html",
"hash": "1hBpTu8Nzy/eqi7qf3RQfQ=="
}
},
"is_incremental": false,
"version": "",
"plugin": "add-to-gallery"
},
{
"type": "Resource",
"source_relative_path": "../scripts/aad-inactive-guest-delete/assets/example.png",
"output": {
"resource": {
"relative_path": "aad-inactive-guest-delete/assets/example.png"
}
},
"is_incremental": false,
"version": ""
},
{
"type": "Resource",
"source_relative_path": "../scripts/aad-inactive-guest-delete/assets/preview.png",
"output": {
"resource": {
"relative_path": "aad-inactive-guest-delete/assets/preview.png"
}
},
"is_incremental": false,
"version": ""
},
{
"type": "Resource",
"source_relative_path": "../scripts/aad-inactive-guest-delete/assets/sample.json",
"output": {
"resource": {
"relative_path": "aad-inactive-guest-delete/assets/sample.json"
}
},
"is_incremental": false,
"version": ""
},
{
"type": "Conceptual",
"source_relative_path": "../scripts/aad-replace-membership-of-selected-groups/README.md",
Expand Down Expand Up @@ -14566,7 +14612,7 @@
"output": {
".html": {
"relative_path": "cmdusage.html",
"hash": "QG1RcR5/9hBuEzXwn44cXg=="
"hash": "Kxv6DhofGEv38V+yLKMomQ=="
}
},
"is_incremental": false,
Expand Down Expand Up @@ -14699,7 +14745,7 @@
"output": {
".html": {
"relative_path": "matrix.html",
"hash": "F32md/MMoZ9IiiyCEFZ1aQ=="
"hash": "SPF7gugNw26/d0rR5dGR0g=="
}
},
"is_incremental": false,
Expand All @@ -14711,7 +14757,7 @@
"output": {
".html": {
"relative_path": "metadata.html",
"hash": "EHNmOwjtEb//QI6P3OOZbg=="
"hash": "3r33BaMyvKQc5cBUnYBasw=="
}
},
"is_incremental": false,
Expand Down
Loading

0 comments on commit 7f15b4f

Please sign in to comment.