Skip to content

Commit 1a02225

Browse files
chore: Bump module version to 1.0.12 (#13)
1 parent cd3ef01 commit 1a02225

14 files changed

Lines changed: 133 additions & 23 deletions

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Before installing the module, the following prerequisites must be fulfilled:
7777
Connect-M365Tenant
7878
```
7979

80-
> **Note:** This may prompt you up to 7 times for username/password, please make sure to follow the instructions in the PowerShell session. You also need to consent to the "Pnp.PowerShell" and "Microsoft Graph" module accessing your tenant. If a browser dont open, or it hangs, cancel the operation and rerun the "Connect-M365Tenant" cmdlet again.
80+
> **Note:** This may prompt you up to 9 times for username/password, please make sure to follow the instructions in the PowerShell session. You also need to consent to the "Pnp.PowerShell" and "Microsoft Graph" module accessing your tenant. If a browser dont open, or it hangs, cancel the operation and rerun the "Connect-M365Tenant" cmdlet again.
8181
8282
5. After a successful connection to the Microsoft 365 tenant, run the assessment.
8383

@@ -116,6 +116,8 @@ Link to a small video (in GIF-format) with the module in action, can be found [h
116116

117117
Microsoft.Graph.Authentication
118118

119+
Microsoft.Graph.Applications
120+
119121
Microsoft.Graph.Groups
120122

121123
Microsoft.Graph.Users

src/SystemAdmins.M365Assessment/SystemAdmins.M365Assessment.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
RootModule = 'SystemAdmins.M365Assessment.psm1';
44

55
# Version number of this module.
6-
ModuleVersion = '1.0.11';
6+
ModuleVersion = '1.0.12';
77

88
# Supported PSEditions
99
CompatiblePSEditions = @('Core');

src/SystemAdmins.M365Assessment/SystemAdmins.M365Assessment.psm1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ if ($null -ne $installedModules)
7777

7878
# Throw warning.
7979
Write-CustomLog -Message ('Not all required modules are installed, please run "Install-M365Dependency"') -Level Warning -NoDateTime -NoLogLevel;
80-
Write-CustomLog -Message ('Modules that need to be (re)installed is "{0}"' -f (($installedModules).Name) -join '", "') -Level Warning -NoDateTime -NoLogLevel;
8180
Write-CustomLog -Message ('Then restart the PowerShell session and import the module again') -Level Warning -NoDateTime -NoLogLevel;
8281
}
8382
# Else all modules are installed.

src/SystemAdmins.M365Assessment/private/configuration/Set-Configuration.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Modules used by the this module.
22
$script:Modules = [PSCustomObject]@{
33
'Microsoft.Graph.Authentication' = 'latest';
4+
'Microsoft.Graph.Applications' = 'latest';
45
'Microsoft.Graph.Groups' = 'latest';
56
'Microsoft.Graph.Users' = 'latest';
67
'Microsoft.Graph.Identity.DirectoryManagement' = 'latest';
@@ -17,4 +18,7 @@ $script:Modules = [PSCustomObject]@{
1718
};
1819

1920
# Temp path.
20-
$script:TempPath = [io.path]::GetTempPath();
21+
$script:TempPath = [io.path]::GetTempPath();
22+
23+
# PnP PowerShell settings.
24+
$script:PnPPowerShellApplicationName = 'SystemAdmins.M365Assessment.PnPPowerShell';

src/SystemAdmins.M365Assessment/private/helper/connection/Test-M365Connection.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function Test-M365Connection
6060
try
6161
{
6262
# Test connection to Azure.
63-
$null = Get-AzAccessToken -ErrorAction Stop;
63+
$null = Get-AzAccessToken -AsSecureString -WarningAction SilentlyContinue -ErrorAction Stop | ConvertFrom-SecureString;
6464
$connections.Azure = $true;
6565
}
6666
catch

src/SystemAdmins.M365Assessment/private/helper/m365/api/Get-FabricApiToken.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function Get-FabricApiToken
2929
Write-CustomLog -Category 'API' -Subcategory 'Microsoft Fabric' -Message ('Getting access token') -Level Verbose;
3030

3131
# Get Azure token for Microsoft Fabric.
32-
$azToken = Get-AzAccessToken -ResourceUrl $uri;
32+
$azToken = Get-AzAccessToken -AsSecureString -WarningAction SilentlyContinue -ResourceUrl $uri | ConvertFrom-SecureString;
3333

3434
# If the access token is null.
3535
if ($null -eq $azToken.Token)

src/SystemAdmins.M365Assessment/private/helper/m365/api/Get-MsAdminApiToken.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function Get-MsAdminApiToken
4242
Write-CustomLog -Category 'API' -Subcategory 'Admin API' -Message ('Getting access token for Microsoft Admin API') -Level Verbose;
4343

4444
# Get access token.
45-
$accessToken = (Get-AzAccessToken -ResourceUrl $resourceUrl).Token;
45+
$accessToken = (Get-AzAccessToken -AsSecureString -WarningAction SilentlyContinue -ResourceUrl $resourceUrl).Token | ConvertFrom-SecureString;
4646

4747
# Write to log.
4848
Write-CustomLog -Category 'API' -Subcategory 'Admin API' -Message ('Successfully got access token for Microsoft Admin API') -Level Verbose;

src/SystemAdmins.M365Assessment/private/helper/m365/api/Invoke-EntraIdAccessReviewApi.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
BEGIN
3838
{
3939
# Get access token for Entra ID Access Review API.
40-
$accessToken = (Get-AzAccessToken).Token;
40+
$accessToken = (Get-AzAccessToken -AsSecureString -WarningAction SilentlyContinue).Token | ConvertFrom-SecureString;
4141

4242
# Construct the headers for the request.
4343
$headers = @{

src/SystemAdmins.M365Assessment/private/helper/m365/api/Invoke-EntraIdRbacApi.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@
3737
BEGIN
3838
{
3939
# Get access token for Entra ID.
40-
$accessToken = (Get-AzAccessToken -ResourceUrl 'https://api.azrbac.mspim.azure.com').Token;
40+
$accessToken = (Get-AzAccessToken -AsSecureString -ResourceUrl 'https://api.azrbac.mspim.azure.com' -WarningAction SilentlyContinue).Token | ConvertFrom-SecureString;
4141

4242
# Construct the headers for the request.
4343
$headers = @{
4444
'Content-Type' ='application/json; charset=UTF-8';
45-
'Authorization' = ('Bearer {0}' -f $accessToken);
45+
'Authorization' = ('Bearer {0}' -f $accessToken);
4646
'x-ms-client-request-id' = [guid]::NewGuid();
4747
'x-ms-correlation-id' = [guid]::NewGuid();
4848
};
@@ -67,13 +67,13 @@
6767
try
6868
{
6969
# Write to log.
70-
Write-CustomLog -Category "API" -Subcategory 'Entra ID' -Message ('Trying to call RBAC API with the method "{0}" and the URL "{1}"' -f $Method, $Uri) -Level Verbose;
70+
Write-CustomLog -Category 'API' -Subcategory 'Entra ID' -Message ('Trying to call RBAC API with the method "{0}" and the URL "{1}"' -f $Method, $Uri) -Level Verbose;
7171

7272
# Invoke API.
7373
$response = Invoke-RestMethod @param -ErrorAction Stop;
7474

7575
# Write to log.
76-
Write-CustomLog -Category "API" -Subcategory 'Entra ID' -Message ('Successfully called RBAC API with the method "{0}" and the URL "{1}"' -f $Method, $Uri) -Level Verbose;
76+
Write-CustomLog -Category 'API' -Subcategory 'Entra ID' -Message ('Successfully called RBAC API with the method "{0}" and the URL "{1}"' -f $Method, $Uri) -Level Verbose;
7777
}
7878
# Something went wrong while invoking API.
7979
catch
@@ -92,6 +92,6 @@
9292
}
9393

9494
# Write to log.
95-
Write-CustomLog -Category "API" -Subcategory 'Entra ID' -Message ('Response from RBAC API is empty') -Level Verbose;
95+
Write-CustomLog -Category 'API' -Subcategory 'Entra ID' -Message ('Response from RBAC API is empty') -Level Verbose;
9696
}
9797
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
function Get-EntraIdApplicationPnpPowerShell
2+
{
3+
<#
4+
.SYNOPSIS
5+
Search after the Entra ID application used to connect to SharePoint with PnP.PowerShell.
6+
.DESCRIPTION
7+
Returns application object.
8+
.NOTES
9+
Requires the following modules:
10+
- Microsoft.Graph.Applications
11+
.EXAMPLE
12+
Get-EntraIdApplicationPnpPowerShell;
13+
#>
14+
15+
[cmdletbinding()]
16+
param
17+
(
18+
# Display name of the application.
19+
[Parameter(Mandatory = $true)]
20+
[string]$DisplayName
21+
)
22+
23+
BEGIN
24+
{
25+
# Write to log.
26+
Write-CustomLog -Category 'Entra' -Subcategory 'Application' -Message 'Getting PnP.PowerShell application' -Level Verbose;
27+
28+
# Search after the application.
29+
$applications = Get-MgApplication -ConsistencyLevel 'Eventual' -Search ('"DisplayName:{0}"' -f $DisplayName);
30+
31+
# Variable for application.
32+
$application = $null;
33+
}
34+
PROCESS
35+
{
36+
# If no application was found.
37+
if ($applications.Count -eq 0)
38+
{
39+
# Write to log.
40+
Write-CustomLog -Category 'Entra' -Subcategory 'Application' -Message 'No PnP.PowerShell application found' -Level Warning;
41+
}
42+
# Else if multiple applications were found.
43+
elseif ($applications.Count -gt 1)
44+
{
45+
# Write to log.
46+
Write-CustomLog -Category 'Entra' -Subcategory 'Application' -Message 'Multiple PnP.PowerShell applications found' -Level Warning;
47+
48+
# Get the first application.
49+
$application = $applications[0];
50+
51+
# Write to log.
52+
Write-CustomLog -Category 'Entra' -Subcategory 'Application' -Message ("Using the first application '{0}'" -f $application.Id) -Level Verbose;
53+
}
54+
# Else if only one application was found.
55+
else
56+
{
57+
# Get the application.
58+
$application = $applications;
59+
60+
# Write to log.
61+
Write-CustomLog -Category 'Entra' -Subcategory 'Application' -Message ("Using the application '{0}'" -f $application.Id) -Level Verbose;
62+
}
63+
}
64+
END
65+
{
66+
# If application was found.
67+
if ($null -ne $application)
68+
{
69+
# Return application.
70+
return $application;
71+
}
72+
}
73+
}

0 commit comments

Comments
 (0)