Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions src/powershell/Initialize-Dependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ function Initialize-Dependencies {
[Microsoft.PowerShell.Commands.ModuleSpecification[]]$externalModuleDependencies = $moduleManifest.PrivateData.ExternalModuleDependencies

[Microsoft.PowerShell.Commands.ModuleSpecification[]]$xPlatPowerShellRequiredModules = @(
@{ModuleName = 'Microsoft.Graph.Authentication'; GUID = '883916f2-9184-46ee-b1f8-b6a2fb784cee'; ModuleVersion = '2.32.0'; },
@{ModuleName = 'Microsoft.Graph.Beta.Teams'; GUID = 'e264919d-7ae2-4a89-ba8b-524bd93ddc08'; ModuleVersion = '2.32.0'; },
@{ModuleName = 'Microsoft.Graph.Authentication'; GUID = '883916f2-9184-46ee-b1f8-b6a2fb784cee'; ModuleVersion = '2.35.1'; },
@{ModuleName = 'Microsoft.Graph.Beta.Teams'; GUID = 'e264919d-7ae2-4a89-ba8b-524bd93ddc08'; ModuleVersion = '2.35.1'; },
@{ModuleName = 'Az.Accounts'; GUID = '17a2feff-488b-47f9-8729-e2cec094624c'; ModuleVersion = '4.0.2'; },
@{ModuleName = 'ExchangeOnlineManagement'; GUID = 'b5eced50-afa4-455b-847a-d8fb64140a22'; RequiredVersion = '3.9.0'; }
)
Expand Down Expand Up @@ -178,6 +178,7 @@ function Initialize-Dependencies {
{
if ($saveModuleCmd.Name -eq 'Save-PSResource')
{
#TODO: use the find before piping result to Save-PSResource.
$saveModuleCmdParamsClone['Name'] = $moduleSpec.Name
# Save-PSResource uses NuGet version range syntax: https://learn.microsoft.com/en-us/nuget/concepts/package-versioning?tabs=semver20sort#version-ranges
if ($moduleSpec.RequiredVersion) {
Expand Down
2 changes: 1 addition & 1 deletion src/powershell/ZeroTrustAssessment.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ FunctionsToExport = 'Connect-ZtAssessment', 'Disconnect-ZtAssessment',
'Get-ZtExportStatistics', 'Get-ZtGraphScope', 'Get-ZtTest',
'Get-ZtTestStatistics', 'Invoke-ZtAssessment',
'Invoke-ZtGraphRequest', 'Invoke-ZtAzureRequest',
'Invoke-ZtAzureResourceGraphRequest'
'Invoke-ZtAzureResourceGraphRequest', 'Clear-ZtRequiredModules'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
Expand Down
41 changes: 41 additions & 0 deletions src/powershell/public/Clear-ZtRequiredModules.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
param ()

function Clear-ZtRequiredModules {
[CmdletBinding()]
param (
)

# If CallStack from the Module file (psm1), the module is being loaded.
if ((Get-PSCallStack).Position.File -like '*ZeroTrustAssessment.psm1')
{
Write-Verbose -Message 'Command is being called from module loading. Ignoring.'
return
}
elseif ($MyInvocation.MyCommand.Module) # Called when module is loaded.
{
Write-Warning -Message 'This command cannot be run when the module is loaded.'
Write-Warning -Message 'Please close all sessions where ZeroTrustAssessment module is loaded, then run the following...'
Write-Warning -Message ('&''{0}''' -f $PSCommandPath)
Set-Clipboard -Value ('&''{0}''' -f $PSCommandPath)
Write-Warning -Message ('(The command has been copied to your clipboard.)')
return
}
else
{
Write-Verbose -Message 'Clearing ZTA required modules from the current session.'
}

# Remove all ZTA-related modules from the current session
if ($isWindows) {
$ZTAModulesFolder = Join-Path -Path $Env:APPDATA -ChildPath 'ZeroTrustAssessment\Modules'
}
else {
$ZTAModulesFolder = Join-Path -Path $Env:HOME -ChildPath '.cache/ZeroTrustAssessment/Modules'
}

if (Test-Path -Path $ZTAModulesFolder) {
Remove-Item -Path $ZTAModulesFolder -Recurse -Force -ErrorAction Continue
}
}

Clear-ZtRequiredModules @PSBoundParameters
4 changes: 2 additions & 2 deletions src/powershell/public/Connect-ZtAssessment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ function Connect-ZtAssessment {
[switch]
$SkipAzureConnection,

# The services to connect to such as Azure and ExchangeOnline. Default is Graph.
# The services to connect to such as Azure and ExchangeOnline. Default is All.
[ValidateSet('All', 'Azure', 'AipService', 'ExchangeOnline', 'Graph', 'SecurityCompliance', 'SharePointOnline')]
[string[]]$Service = 'Graph',
[string[]]$Service = 'All',

# The Exchange environment to connect to. Default is O365Default. Supported values include O365China, O365Default, O365GermanyCloud, O365USGovDoD, O365USGovGCCHigh.
[ValidateSet('O365China', 'O365Default', 'O365GermanyCloud', 'O365USGovDoD', 'O365USGovGCCHigh')]
Expand Down
Loading