mirror of
https://github.com/Micke-K/IntuneManagement.git
synced 2026-09-28 19:05:38 +02:00
IntuneManagement 4.0.0-beta1
This commit is contained in:
@@ -0,0 +1,168 @@
|
||||
#ImportOrder 5
|
||||
|
||||
class LogViewObject : ViewObjectBase
|
||||
{
|
||||
LogViewObject() : base()
|
||||
{
|
||||
$this.Init()
|
||||
}
|
||||
|
||||
Hidden Init()
|
||||
{
|
||||
$this._ID = "CoreLog"
|
||||
$this._Title = "Log"
|
||||
$this._Description = "View log items"
|
||||
$this._HideMenu = $true
|
||||
}
|
||||
|
||||
[Object]GetViewPanel()
|
||||
{
|
||||
# ToDo: Remove recreate panel each time
|
||||
#if($null -eq $this._ViewPanel) {
|
||||
$this._ViewPanel = Get-LogViewPanel
|
||||
#}
|
||||
return $this._ViewPanel
|
||||
}
|
||||
|
||||
[Object[]]GetViewItems()
|
||||
{
|
||||
return $null
|
||||
}
|
||||
|
||||
Authenticate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Object[]]OnItemChanged($SelectedItem)
|
||||
{
|
||||
return $null
|
||||
}
|
||||
|
||||
OnDeactivating($NewActiveView)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
OnActivating($PreviousActiveView)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
OnActivated()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class CachedObjectsViewObject : ViewObjectBase
|
||||
{
|
||||
CachedObjectsViewObject() : base()
|
||||
{
|
||||
$this.Init()
|
||||
}
|
||||
|
||||
Hidden Init()
|
||||
{
|
||||
$this._ID = "CoreCachedObjects"
|
||||
$this._Title = "Cached Objects"
|
||||
$this._Description = "View cached items"
|
||||
$this._HideMenu = $true
|
||||
}
|
||||
|
||||
[Object]GetViewPanel()
|
||||
{
|
||||
# ToDo: Remove recreate panel each time
|
||||
#if($null -eq $this._ViewPanel) {
|
||||
$this._ViewPanel = Get-CachedObjectsViewPanel
|
||||
#}
|
||||
return $this._ViewPanel
|
||||
}
|
||||
|
||||
[Object[]]GetViewItems()
|
||||
{
|
||||
return $null
|
||||
}
|
||||
|
||||
Authenticate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Object[]]OnItemChanged($SelectedItem)
|
||||
{
|
||||
return $null
|
||||
}
|
||||
|
||||
OnDeactivating($NewActiveView)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
OnActivating($PreviousActiveView)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
OnActivated()
|
||||
{
|
||||
if($this._ViewPanel) {
|
||||
Update-CachedObjectsView -ViewPanel $this._ViewPanel
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GraphCallsViewObject : ViewObjectBase
|
||||
{
|
||||
GraphCallsViewObject() : base()
|
||||
{
|
||||
$this.Init()
|
||||
}
|
||||
|
||||
Hidden Init()
|
||||
{
|
||||
$this._ID = "GraphCalls"
|
||||
$this._Title = "Graph Calls"
|
||||
$this._Description = "View all calls to Microsoft Graph"
|
||||
$this._HideMenu = $true
|
||||
}
|
||||
|
||||
[Object]GetViewPanel()
|
||||
{
|
||||
# ToDo: Remove recreate panel each time
|
||||
#if($null -eq $this._ViewPanel) {
|
||||
$this._ViewPanel = Get-GraphCallsViewPanel
|
||||
#}
|
||||
return $this._ViewPanel
|
||||
}
|
||||
|
||||
[Object[]]GetViewItems()
|
||||
{
|
||||
return $null
|
||||
}
|
||||
|
||||
Authenticate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Object[]]OnItemChanged($SelectedItem)
|
||||
{
|
||||
return $null
|
||||
}
|
||||
|
||||
OnDeactivating($NewActiveView)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
OnActivating($PreviousActiveView)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
OnActivated()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
#ImportOrder 160
|
||||
class IntuneToolsViewObject : ViewObjectBase
|
||||
{
|
||||
IntuneToolsViewObject() : Base()
|
||||
{
|
||||
$this.Init()
|
||||
}
|
||||
|
||||
Hidden Init()
|
||||
{
|
||||
$this._ID = "IntuneTools"
|
||||
$this._Title = "Intune Tools"
|
||||
$this._Description = "Tools that operate on Intune objects, such as listing assignments across all object types."
|
||||
$this._AddToMenu = $true
|
||||
# Tools list is short and curated — fine to also surface in the top
|
||||
# Views menu as a submenu (one entry per tool, grouped by Category).
|
||||
$this._ExpandInViewsMenu = $true
|
||||
}
|
||||
|
||||
[Object]GetViewPanel()
|
||||
{
|
||||
if($null -eq $this._ViewPanel)
|
||||
{
|
||||
$this._ViewPanel = Get-IntuneToolsViewPanel
|
||||
}
|
||||
return $this._ViewPanel
|
||||
}
|
||||
|
||||
[PSCustomObject[]]GetViewItems()
|
||||
{
|
||||
return @(Get-IntuneToolsViewItems)
|
||||
}
|
||||
|
||||
Authenticate()
|
||||
{
|
||||
# Auto-login policy: silent-only. If the silent path fails the user signs in
|
||||
# explicitly via the Login button — we never pop an unbidden OAuth window
|
||||
# from a view-activation event.
|
||||
#
|
||||
# Also gated to MSAL provider so MgGraph mode isn't hijacked by a successful
|
||||
# MSAL silent auth here.
|
||||
$active = $null
|
||||
try { $active = Get-AuthProvider } catch { }
|
||||
if($active) { $active.RefreshAmbientSession() }
|
||||
}
|
||||
|
||||
[Object[]]OnItemChanged($SelectedItem)
|
||||
{
|
||||
return (Invoke-IntuneToolsActivateItem $SelectedItem)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
#ImportOrder 150
|
||||
class IntuneViewObject : ViewObjectBase
|
||||
{
|
||||
Hidden [IntunePolicyBase[]]$_Items = @()
|
||||
|
||||
IntuneViewObject() : Base()
|
||||
{
|
||||
$this.Init()
|
||||
}
|
||||
|
||||
Hidden Init()
|
||||
{
|
||||
$this._ID = "IntuneManagement"
|
||||
$this._Title = "Intune Manager"
|
||||
$this._Description = "Manages Intune environments. This view can be used for copying objects in an Intune environment. It can also be used for backing up an entire Intune environment and cloning the Intune environment into another tenant."
|
||||
$this._AddToMenu = $false
|
||||
}
|
||||
|
||||
[Object]GetViewPanel()
|
||||
{
|
||||
if($null -eq $this._ViewPanel) {
|
||||
$this._ViewPanel = Get-IntuneManagementViewPanel
|
||||
}
|
||||
return $this._ViewPanel
|
||||
}
|
||||
|
||||
[PSCustomObject[]]GetViewItems()
|
||||
{
|
||||
return @(Get-IntuneViewItems)
|
||||
}
|
||||
|
||||
Authenticate()
|
||||
{
|
||||
# Auto-login policy: at startup / view activation we only attempt SILENT auth
|
||||
# against the last-logged-on account. If it fails we surface "signed out" and
|
||||
# wait for the user to click the Login button. We do NOT pop an interactive
|
||||
# OAuth prompt unbidden — that would steal focus from whatever the user is
|
||||
# doing and contradict the explicit-login design.
|
||||
#
|
||||
# Also gated to MSAL provider so MgGraph mode isn't hijacked (a successful
|
||||
# silent MSAL auth here would flip the active provider).
|
||||
$active = $null
|
||||
try { $active = Get-AuthProvider } catch { }
|
||||
if($active) { $active.RefreshAmbientSession() }
|
||||
}
|
||||
|
||||
[Object[]]OnItemChanged($SelectedItem)
|
||||
{
|
||||
return (Invoke-IntuneActivateObject $SelectedItem)
|
||||
}
|
||||
|
||||
OnDeactivating($NewActiveView)
|
||||
{
|
||||
Invoke-IntuneDeactivatingView $NewActiveView
|
||||
}
|
||||
|
||||
OnActivating($PreviousActiveView)
|
||||
{
|
||||
Invoke-IntuneActivatingView $PreviousActiveView
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
#ImportOrder 60
|
||||
#
|
||||
# WPF concrete subclass of UIProvider. Each method captures the
|
||||
# corresponding free function from CoreUIWPF.ps1 (and friends) at construction
|
||||
# time via ${function:X}, then invokes the captured scriptblock with `&`.
|
||||
# This is defensive: PS native class methods *may* see module-scoped free
|
||||
# functions, but the documented workaround for ScriptMethod scriptblocks
|
||||
# (see [[scriptmethod-loses-module-scope]]) is the capture pattern. Until a
|
||||
# smoke test confirms direct calls work, we capture explicitly.
|
||||
#
|
||||
# Folder picking delegates to the existing WPF Get-Folder helper. Open/save
|
||||
# file dialogs are intentionally not part of the base provider until both
|
||||
# backends have an implemented contract.
|
||||
|
||||
class WPFUIProvider : UIProvider {
|
||||
|
||||
#region Modal / dialog
|
||||
|
||||
[void] ShowMessageBox([string]$Text) {
|
||||
$f = ${function:Show-MessageBox}
|
||||
& $f $Text | Out-Null
|
||||
}
|
||||
|
||||
[void] ShowMessageBox([string]$Text, [string]$Caption) {
|
||||
$f = ${function:Show-MessageBox}
|
||||
& $f $Text $Caption | Out-Null
|
||||
}
|
||||
|
||||
[object] ShowMessageBox([string]$Text, [string]$Caption, [string]$Button, [string]$Icon) {
|
||||
$f = ${function:Show-MessageBox}
|
||||
return (& $f $Text $Caption $Button $Icon)
|
||||
}
|
||||
|
||||
[void] ShowModalForm([string]$FormTitle, [object]$FormObject) {
|
||||
$f = ${function:Show-ModalForm}
|
||||
& $f $FormTitle $FormObject
|
||||
}
|
||||
|
||||
[void] ShowModalForm([string]$FormTitle, [object]$FormObject, [bool]$HideButtons) {
|
||||
$f = ${function:Show-ModalForm}
|
||||
if ($HideButtons) { & $f $FormTitle $FormObject -HideButtons }
|
||||
else { & $f $FormTitle $FormObject }
|
||||
}
|
||||
|
||||
[void] ShowModalObject() {
|
||||
$f = ${function:Show-ModalObject}
|
||||
& $f
|
||||
}
|
||||
|
||||
[void] ShowModalObject([object]$Obj) {
|
||||
$f = ${function:Show-ModalObject}
|
||||
& $f $Obj
|
||||
}
|
||||
|
||||
[void] CloseTopModalObject() {
|
||||
$f = ${function:Close-TopModalObject}
|
||||
& $f
|
||||
}
|
||||
|
||||
[string] ShowInputDialog([string]$FormTitle, [string]$FormText, [string]$DefaultValue) {
|
||||
$f = ${function:Show-InputDialog}
|
||||
return (& $f $FormTitle $FormText $DefaultValue)
|
||||
}
|
||||
|
||||
[void] ShowAboutDialog() {
|
||||
$f = ${function:Show-AboutDialog}
|
||||
& $f
|
||||
}
|
||||
|
||||
[bool] RequestUIConfirmation([string]$Message, [string]$Caption) {
|
||||
$f = ${function:Request-UIConfirmation}
|
||||
return [bool](& $f $Message $Caption)
|
||||
}
|
||||
|
||||
[void] ShowPopup([object]$Popup) {
|
||||
$f = ${function:Show-Popup}
|
||||
& $f $Popup
|
||||
}
|
||||
|
||||
[void] HidePopup() {
|
||||
$f = ${function:Hide-Popup}
|
||||
& $f
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region File / folder pickers
|
||||
|
||||
[string] ShowFolderPicker([string]$Description) {
|
||||
$f = ${function:Get-Folder}
|
||||
return (& $f -Title $Description)
|
||||
}
|
||||
|
||||
[string] ShowFolderPicker([string]$Path, [string]$Description) {
|
||||
$f = ${function:Get-Folder}
|
||||
return (& $f -Path $Path -Title $Description)
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region XAML helpers
|
||||
|
||||
[object] GetXamlObject([string]$FileName) {
|
||||
$f = ${function:Get-XamlObject}
|
||||
return (& $f $FileName)
|
||||
}
|
||||
|
||||
[object] GetXamlObject([string]$FileName, [bool]$AddVariables) {
|
||||
$f = ${function:Get-XamlObject}
|
||||
if ($AddVariables) { return (& $f $FileName -AddVariables) }
|
||||
else { return (& $f $FileName) }
|
||||
}
|
||||
|
||||
[object] GetXamlObject([string]$FileName, [bool]$AddVariables, [bool]$AddStyles) {
|
||||
$f = ${function:Get-XamlObject}
|
||||
$h = @{}
|
||||
if ($AddVariables) { $h.AddVariables = $true }
|
||||
if ($AddStyles) { $h.AddStyles = $true }
|
||||
return (& $f $FileName @h)
|
||||
}
|
||||
|
||||
[void] AddXamlEvent([object]$XamlObj, [string]$ControlName, [string]$EventName, [scriptblock]$Handler) {
|
||||
$f = ${function:Add-XamlEvent}
|
||||
& $f $XamlObj $ControlName $EventName $Handler
|
||||
}
|
||||
|
||||
[void] AddXamlVariables([object]$XamlObj, [object]$Scope) {
|
||||
$f = ${function:Add-XamlVariables}
|
||||
& $f $XamlObj $Scope
|
||||
}
|
||||
|
||||
[void] SetXamlProperty([object]$XamlObj, [string]$ControlName, [string]$PropertyName, [object]$Value) {
|
||||
$f = ${function:Set-XamlProperty}
|
||||
& $f $XamlObj $ControlName $PropertyName $Value
|
||||
}
|
||||
|
||||
[object] GetXamlProperty([object]$XamlObj, [string]$ControlName, [string]$PropertyName) {
|
||||
$f = ${function:Get-XamlProperty}
|
||||
return (& $f $XamlObj $ControlName $PropertyName)
|
||||
}
|
||||
|
||||
[void] SetControlVisible([object]$XamlObj, [string]$ControlName, [bool]$Visible) {
|
||||
$value = if ($Visible) { "Visible" } else { "Collapsed" }
|
||||
$this.SetXamlProperty($XamlObj, $ControlName, "Visibility", $value)
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Main window / chrome
|
||||
|
||||
[void] ShowMainWindow([object]$View) {
|
||||
$f = ${function:Show-MainWindow}
|
||||
& $f $View
|
||||
}
|
||||
|
||||
[void] SetMainTitle() {
|
||||
$f = ${function:Set-MainTitle}
|
||||
& $f
|
||||
}
|
||||
|
||||
[object] GetMainWindow() {
|
||||
$f = ${function:Get-MainWindow}
|
||||
return (& $f)
|
||||
}
|
||||
|
||||
[void] SetAppTheme([string]$ThemeName) {
|
||||
$f = ${function:Set-AppTheme}
|
||||
& $f $ThemeName
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Threading / status
|
||||
|
||||
[void] UpdateUIStatus([string]$Text) {
|
||||
$f = ${function:Update-UIStatus}
|
||||
& $f -Text $Text | Out-Null
|
||||
}
|
||||
|
||||
[bool] UpdateUIStatus([System.Collections.IDictionary]$Params) {
|
||||
$f = ${function:Update-UIStatus}
|
||||
$h = @{}
|
||||
foreach ($k in $Params.Keys) { $h[$k] = $Params[$k] }
|
||||
return [bool](& $f @h)
|
||||
}
|
||||
|
||||
[void] InvokeUIMessagePump() {
|
||||
$f = ${function:Invoke-UIMessagePump}
|
||||
& $f
|
||||
}
|
||||
|
||||
[void] SetClipboardText([string]$Text) {
|
||||
# Clipboard.SetText throws on null/empty; Clear() is the empty equivalent.
|
||||
if([string]::IsNullOrEmpty($Text)) { [System.Windows.Clipboard]::Clear(); return }
|
||||
[System.Windows.Clipboard]::SetText($Text)
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Auth chrome
|
||||
|
||||
[void] ShowAuthenticationInfo() {
|
||||
$f = ${function:Show-AuthenticationInfo}
|
||||
& $f
|
||||
}
|
||||
|
||||
[void] SetEnvironmentInfo() {
|
||||
$f = ${function:Set-EnvironmentInfo}
|
||||
& $f
|
||||
}
|
||||
|
||||
[void] SetEnvironmentInfo([string]$TenantName) {
|
||||
$f = ${function:Set-EnvironmentInfo}
|
||||
& $f $TenantName
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user