How paulpalayur/wpmexport works
What this project is (type + purpose)
This repo is a PowerShell-based export utility (“wpmexport”) that runs as a local script/CLI. Its purpose is to export a user’s personal WPM objects (notably Secured Items and Web Apps) by authenticating against an Identity tenant (including shared services tenants and federated users), calling the relevant remote APIs, and writing results to a local export.csv.
From the tree and README, the architecture is not a multi-service app; it’s a script orchestrator + an authentication module + remote SaaS APIs + local file output.
How to read the file structure (what maps to “components”)
• Export-WPM.ps1
• The main entrypoint (orchestrator). Prompts for:
• Identity Tenant Id
• Identity User Name
• subdomain
• Then likely:
• acquires tokens via the Identity Authentication module
• calls WPM/Identity endpoints to list/export objects
• transforms results
• writes export.csv
• Identity Authentication/IdentityAuth.psm1
• A reusable PowerShell module (component) responsible for:
• authentication flows
• token acquisition/refresh
• handling federated/shared-services nuances
• Identity Authentication/IdentityRefresh.ps1 and IdentityRefresh_5.1.ps1
• Ancillary scripts for refreshing tokens / compatibility (notably Windows PowerShell 5.1 vs newer PowerShell).
• These should appear as either:
• “supporting utilities” called by the module, or
• “alternate execution paths” depending on runtime version.
• Identity Authentication/README.md
• Repo README.md
• Defines external behavior: exports secured items + web apps (owned and some shared without creds) and outputs export.csv.
PowerShell Runtime
• Optionally split:
• PowerShell 7+ (pwsh)
• Windows PowerShell 5.1 (because there’s a *_5.1.ps1 refresh script)
Token refresh helpers
• IdentityRefresh.ps1
• IdentityRefresh_5.1.ps1
CSV Writer / Local File System
• Output: export.csv in script directory
Identity Service (Tenant)
• Federation/IdP as a sub-component if the IdentityAuth README indicates a federated flow (e.g., SAML redirect/ADFS/Azure AD)
WPM Service APIs
• Secured Items API
• Web Apps API (owned)
• Web Apps API (shared-by-admin without credentials)
• Even if they’re the same host, splitting by resource makes the flows explicit.
User → Export-WPM.ps1
• Inputs: Tenant Id, Username, Subdomain
Export-WPM.ps1 → IdentityAuth.psm1
• “Authenticate / Acquire Access Token”
Identity Service → IdentityAuth.psm1
• Returns: access token / refresh token / session info
Export-WPM.ps1 → WPM APIs
• Uses token to call:
• “List Secured Items (owned)”
• “List Web Apps (owned)”
• “List Web Apps (shared, no credentials)”
WPM APIs → Export-WPM.ps1
• Returns: JSON payloads / objects
Export-WPM.ps1 → CSV Writer / File System
• Transforms objects → export.csv
• **Export-WPM.ps1 → IdentityAuth.psm1 → IdentityRefresh*.ps1 → Identity Service**
• “Refresh token” or “re-auth”
• Use a conditional note:
• “If running on Windows PowerShell 5.1, use IdentityRefresh_5.1.ps1; else IdentityRefresh.ps1”
Architectural patterns / design principles to highlight
Even though it’s “just a script”, it still has clear architecture:
• Orchestrator + Module separation
• Export-WPM.ps1 is the workflow coordinator.
• IdentityAuth.psm1 encapsulates auth complexity (federated/shared services support).
• Externalized configuration via prompts
• Tenant Id, username, subdomain are runtime-provided inputs.
• API-integration tool
• Main complexity is in auth + API calls + data transformation.
• Compatibility branching
• Separate refresh logic for PowerShell 5.1 indicates runtime-dependent behavior; call this out explicitly.
Components and labels
• export.csv (artifact/output)
Trust boundaries / zones (important here)
• “Local workstation (user-controlled)” vs “Cloud tenant/services”
This makes the security posture clear: tokens cross the boundary; CSV stays local.
Minimal “component inventory” checklist (don’t miss these)
• [ ] Entry point: Export-WPM.ps1
• [ ] Auth module: IdentityAuth.psm1
• [ ] Refresh scripts, including the 5.1 variant
• [ ] Identity tenant endpoints (and optional federated IdP)
• [ ] WPM APIs split by exported object type
• [ ] Output artifact: export.csv
• [ ] Runtime environment: PowerShell (note 5.1 compatibility path)