Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ package-lock.json
ZZBuild-Help.ps1
test1.ps1
helpdoc.ps1
StyleGuide.md
StyleGuide.md
.copilot/
samplescript.ps1
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "PowerShell: Launch Current File",
"type": "PowerShell",
"request": "launch",
"script": "${file}",
"args": [],
"createTemporaryIntegratedConsole": true
}
]
}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fixed module installation logic to correctly register the module after build and import.
- Fixed parameter handling in module manifest and public functions for better consistency.
- Fixed minimum PowerShell version declaration and validation during install.
- Minor internal refactor related to domain-suffix optional parameter handling.

### Changed

- Made the domain suffix optional during app name initialization for greater flexibility in tenant naming conventions.

## [0.2.1] - 2025-03-17

### Added

- Added Get-TkMsalToken cmdlet to retrieve an MSAL token using API calls.
Expand Down
29 changes: 29 additions & 0 deletions Cmdlets_Mapping.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Function Name,Visibility,Used Cmdlets
Connect-TkMsService,Private,"Get-MgUser, Get-MgContext, Get-MgOrganization, Remove-MgContext, Connect-MgGraph, Disconnect-ExchangeOnline, Connect-ExchangeOnline"
ConvertTo-ParameterSplat,Private,Write-AuditLog
Get-TkExistingCert,Private,"Get-ChildItem, Where-Object, Remove-Item, Write-AuditLog"
Get-TkExistingSecret,Private,"Get-Secret, Write-AuditLog"
Get-TkMsalToken,Private,"Invoke-RestMethod, Write-AuditLog"
Initialize-TkAppAuthCertificate,Private,"Get-ChildItem, New-SelfSignedCertificate, Write-AuditLog"
Initialize-TkAppName,Private,Write-AuditLog
Initialize-TkEmailAppParamsObject,Private,
Initialize-TkM365AuditAppParamsObject,Private,
Initialize-TkMemPolicyManagerAppParamsObject,Private,
Initialize-TkModuleEnv,Private,"Install-Module, Import-Module, Get-Module, Write-AuditLog"
Initialize-TkRequiredResourcePermissionObject,Private,"Get-MgServicePrincipal, Find-MgGraphPermission, Write-AuditLog"
New-TkAppRegistration,Private,"Get-ChildItem, New-MgApplication, Write-AuditLog"
New-TkAppSpOauth2Registration,Private,Write-AuditLog
Connect-TkMsService,Private,"Get-MgUser, Get-MgContext, Get-MgOrganization, Remove-MgContext, Connect-MgGraph, Disconnect-ExchangeOnline, Connect-ExchangeOnline"
ConvertTo-ParameterSplat,Private,Write-AuditLog
Get-TkExistingCert,Public,"Get-ChildItem, Where-Object, Remove-Item, Write-AuditLog"
Get-TkExistingSecret,Public,"Get-Secret, Write-AuditLog"
Get-TkMsalToken,Public,"Invoke-RestMethod, Write-AuditLog"
Initialize-TkAppAuthCertificate,Public,"Get-ChildItem, New-SelfSignedCertificate, Write-AuditLog"
Initialize-TkAppName,Public,Write-AuditLog
Initialize-TkEmailAppParamsObject,Public,
Initialize-TkM365AuditAppParamsObject,Public,
Initialize-TkMemPolicyManagerAppParamsObject,Public,
Initialize-TkModuleEnv,Public,"Install-Module, Import-Module, Get-Module, Write-AuditLog"
Initialize-TkRequiredResourcePermissionObject,Public,"Get-MgServicePrincipal, Find-MgGraphPermission, Write-AuditLog"
New-TkAppRegistration,Public,"Get-ChildItem, New-MgApplication, Write-AuditLog"
New-TkAppSpOauth2Registration,Public,Write-AuditLog
42 changes: 23 additions & 19 deletions README.md

Large diffs are not rendered by default.

40 changes: 21 additions & 19 deletions README2.md

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions RequiredModules.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@
ChangelogManagement = 'latest'
Sampler = 'latest'
'Sampler.GitHubTasks' = 'latest'


}

10 changes: 6 additions & 4 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
<auto-generated>
<synopsis>
This code was generated by a psDoc. on: 03/17/2025 08:59:20
This code was generated by a psDoc. on: 10/06/2025 09:44:12
Get it here: https://github.com/ChaseFlorell/psDoc
</synopsis>
<description>
Expand Down Expand Up @@ -271,7 +271,9 @@ <h3> Syntax </h3>
</div>
<div class="panel panel-default">
<div class='panel-body'>
<pre class="brush: ps">Publish-TkEmailApp [-AppPrefix &lt;String&gt;] -AuthorizedSenderUserName &lt;String&gt; -MailEnabledSendingGroup &lt;String&gt; [-CertPrefix &lt;String&gt;] [-CertThumbprint &lt;String&gt;] [-KeyExportPolicy &lt;String&gt;] [-VaultName &lt;String&gt;] [-OverwriteVaultSecret] [-ReturnParamSplat] [-DoNotUseDomainSuffix] [-LogOutput &lt;String&gt;] [-WhatIf] [-Confirm] [&lt;CommonParameters&gt;]
<pre class="brush: ps">Publish-TkEmailApp [-WhatIf] [-Confirm] [&lt;CommonParameters&gt;]

Publish-TkEmailApp [-AppPrefix &lt;String&gt;] -AuthorizedSenderUserName &lt;String&gt; -MailEnabledSendingGroup &lt;String&gt; [-CertPrefix &lt;String&gt;] [-CertThumbprint &lt;String&gt;] [-KeyExportPolicy &lt;String&gt;] [-VaultName &lt;String&gt;] [-OverwriteVaultSecret] [-ReturnParamSplat] [-DoNotUseDomainSuffix] [-LogOutput &lt;String&gt;] [-WhatIf] [-Confirm] [&lt;CommonParameters&gt;]

Publish-TkEmailApp -ExistingAppObjectId &lt;String&gt; -CertPrefix &lt;String&gt; [-CertThumbprint &lt;String&gt;] [-KeyExportPolicy &lt;String&gt;] [-VaultName &lt;String&gt;] [-OverwriteVaultSecret] [-ReturnParamSplat] [-DoNotUseDomainSuffix] [-LogOutput &lt;String&gt;] [-WhatIf] [-Confirm] [&lt;CommonParameters&gt;]</pre>
</div>
Expand All @@ -293,7 +295,7 @@ <h3> Parameters </h3>
<tr>
<td><nobr>-AppPrefix</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>The prefix used to initialize the Graph Email App. Must be 2-4 characters, letters, and numbers only. Default is 'Gtk'.</p>
<td><p>The prefix used to initialize the Graph Email App. Must be 2-4 characters, letters, and numbers only. The default value is 'Gtk'.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
Expand Down Expand Up @@ -347,7 +349,7 @@ <h3> Parameters </h3>
<tr>
<td><nobr>-KeyExportPolicy</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>Key export policy for the certificate. Valid values are 'Exportable' and 'NonExportable'. Default is 'NonExportable'.</p>
<td><p>Key export policy for the certificate. Valid values are 'Exportable' and 'NonExportable'. The default value is 'NonExportable'.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
Expand Down
21 changes: 13 additions & 8 deletions help/Publish-TkEmailApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ Publishes a new or existing Graph Email App with specified configurations.

## SYNTAX

### CreateNewApp (Default)
### Interactive (Default)
```
Publish-TkEmailApp [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### CreateNewApp
```
Publish-TkEmailApp [-AppPrefix <String>] -AuthorizedSenderUserName <String> -MailEnabledSendingGroup <String>
[-CertPrefix <String>] [-CertThumbprint <String>] [-KeyExportPolicy <String>] [-VaultName <String>]
Expand Down Expand Up @@ -228,7 +233,7 @@ Must be a valid 40-character hexadecimal string.

```yaml
Type: String
Parameter Sets: (All)
Parameter Sets: CreateNewApp, UseExistingApp
Aliases:

Required: False
Expand All @@ -245,7 +250,7 @@ Default is 'NonExportable'.

```yaml
Type: String
Parameter Sets: (All)
Parameter Sets: CreateNewApp, UseExistingApp
Aliases:

Required: False
Expand All @@ -261,7 +266,7 @@ Otherwise, use the default 'GraphEmailAppLocalStore'.

```yaml
Type: String
Parameter Sets: (All)
Parameter Sets: CreateNewApp, UseExistingApp
Aliases:

Required: False
Expand All @@ -276,7 +281,7 @@ If specified, overwrite the vault secret if it already exists.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Parameter Sets: CreateNewApp, UseExistingApp
Aliases:

Required: False
Expand All @@ -291,7 +296,7 @@ If specified, return the parameter splat for use in other functions.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Parameter Sets: CreateNewApp, UseExistingApp
Aliases:

Required: False
Expand All @@ -306,7 +311,7 @@ Switch to add session domain suffix to the app name.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Parameter Sets: CreateNewApp, UseExistingApp
Aliases:

Required: False
Expand All @@ -321,7 +326,7 @@ If specified, log the output to the console.

```yaml
Type: String
Parameter Sets: (All)
Parameter Sets: CreateNewApp, UseExistingApp
Aliases:

Required: False
Expand Down
6 changes: 6 additions & 0 deletions source/Private/Connect-TkMsService.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ function Connect-TkMsService {
[Switch]
$ExchangeOnline
)
# Used Cmdlets
# Get-MgUser, Get-MgContext, Get-MgOrganization, Remove-MgContext, Connect-MgGraph, Disconnect-ExchangeOnline, Connect-ExchangeOnline

# Begin Logging
if (-not $script:LogString) {
Write-AuditLog -Start
Expand Down Expand Up @@ -160,5 +163,8 @@ function Connect-TkMsService {
}
}
}
else {
Write-AuditLog 'No service specified for connection.'
}
Write-AuditLog -EndFunction
}
23 changes: 13 additions & 10 deletions source/Private/Get-TkExistingCert.ps1
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
<#
.SYNOPSIS
Retrieves an existing certificate from the current user's certificate store based on the provided certificate name.
Retrieves an existing certificate from the current user's certificate store based on the subject name.

.DESCRIPTION
The Get-TkExistingCert function searches for a certificate in the current user's "My" certificate store with a subject that matches the provided certificate name.
If the certificate is found, it logs audit messages and provides instructions for removing the certificate if needed.
If the certificate is not found, it logs an audit message indicating that the certificate does not exist.
The Get-TkExistingCert function searches for a certificate in the current user's certificate store with the specified subject name.
If the certificate exists, it provides instructions on how to remove the certificate and optionally removes it if confirmed by the user.

.PARAMETER CertName
The subject name of the certificate to search for in the current user's certificate store.
The subject name of the certificate to search for in the current user's certificate store.

.EXAMPLE
PS C:\> Get-TkExistingCert -CertName "CN=example.com"
This command searches for a certificate with the subject "CN=example.com" in the current user's certificate store.
PS C:\> Get-TkExistingCert -CertName "CN=example.com"
Searches for a certificate with the subject name "CN=example.com" in the current user's certificate store.
If found, it provides instructions on how to remove the certificate and optionally removes it if confirmed by the user.

.NOTES
Author: DrIOSx
Date: 2025-03-12
Version: 1.0
This function uses the certificate store path 'Cert:\CurrentUser\My' to search for the certificate.
The function logs its operations using the Write-AuditLog cmdlet.
#>
function Get-TkExistingCert {
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
Expand Down
14 changes: 7 additions & 7 deletions source/Private/Get-TkExistingSecret.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ function Get-TkExistingSecret {
[string]$AppName,
[string]$VaultName = 'GraphEmailAppLocalStore'
)
Write-AuditLog -BeginFunction
if (-not $script:LogString) {
Write-AuditLog -Start
}
else {
Write-AuditLog -BeginFunction
}
try {
$ExistingSecret = Get-Secret -Name "$AppName" -Vault $VaultName -ErrorAction SilentlyContinue
if ($ExistingSecret) {
return $true
}
else {
return $false
}
return $null -ne $ExistingSecret
}
finally {
Write-AuditLog -EndFunction
Expand Down
2 changes: 1 addition & 1 deletion source/Private/Get-TkMsalToken.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function Get-TkMsalToken {
}
}
process {
if ($PSCmdlet.ParameterSetName -eq 'ManagedIdentity') {
if ($PSCmdlet.ParameterSetName -eq 'ManagedIdentity' -and $UseManagedIdentity) {
# Managed Identity Authentication (Only Works in Azure-hosted Environments)
try {
$uri = 'http://169.254.169.254/metadata/identity/oauth2/token?resource=https://graph.microsoft.com&api-version=2019-08-01'
Expand Down
Loading