Getting started
Nebula.Automations is a PowerShell module that provides reusable functions for scripting, automation, and integration with cloud services. It is the natural evolution of Nebula.Tools and was created with a specific focus on automation.
Main features currently available:
Send-Mail- send HTML (or plain text) emails via SMTP, with multi-recipient To/Cc/Bcc, multiple attachments, optional auth, and TLS.Test-MgGraphConnection(aliasCheckMGGraphConnection) - connect to Microsoft Graph using application credentials, optionally auto-install the Graph module, and emit a Boolean result.- Logging fallback: if
Nebula.Logis not installed, the module exposes a compatibleWrite-Log(aliasLog-Message) that internally callsWrite-NALog, so scripts usingWrite-Logdo not break.
Both functions are designed to be composable inside automation scripts rather than one-off console utilities.
Quick examples
- Send a daily report with an attachment:
Send-Mail `
-SMTPServer "smtp.contoso.com" `
-UseSsl `
-Credential (Get-Credential) `
-From "automation@contoso.com" `
-To "ops@contoso.com","lead@contoso.com" `
-Subject "Daily report" `
-Body "<h1>Report</h1><p>See attachment.</p>" `
-AttachmentPath "C:\Reports\daily.csv","C:\Reports\chart.pdf"
- Connect to Microsoft Graph using client credentials (app context):
$secret = Get-Content "$env:APPDATA\nebula\.graph_secret.txt" -Raw
$connected = Test-MgGraphConnection `
-TenantId "00000000-0000-0000-0000-000000000000" `
-ClientId "11111111-1111-1111-1111-111111111111" `
-ClientSecret $secret `
-LogLocation "$env:APPDATA\nebula\logs\graph-connect.log" `
-AutoInstall `
-ShowInformations:$false
if (-not $connected) { throw "Unable to connect to Microsoft Graph." }
Every function exposes built-in help. Use Get-Help <FunctionName> -Detailed or -Examples for notes, parameters, and prerequisites.
Requirements
- PowerShell 5.1+ or PowerShell 7+
Send-Mail: no external dependencies; uses .NETSystem.Net.Mail. Supports credentials/TLS when the relay requires them.Test-MgGraphConnection: usesMicrosoft.Graph; can auto-install it when-AutoInstallis set. Logging relies onWrite-LogfromNebula.Log; if that module is missing, Nebula.Automations exposes a compatibleWrite-Log/Log-Messagethat delegates toWrite-NALog.
Logging behavior
- When
Nebula.Logis installed, itsWrite-Logis used. - If
Nebula.Logis missing, Nebula.Automations publishes a compatibleWrite-Log(aliasLog-Message) that delegates toWrite-NALog. This prevents scripts that callWrite-Logfrom failing. Write-NALogonly usesWrite-Logwhen it comes fromNebula.Log; otherwise it writes to the transcript (and, when possible, to a file in the current directory or the supplied-LogLocation).
How to download Nebula.Automations
Nebula.Automations is available on the PowerShell Gallery.
Its GitHub repository is available at github.com/gioxx/Nebula.Automations.
Installation from PowerShell Gallery
This is definitely the recommended option and is currently the simplest, provided your machine has internet connectivity and the ability to download files from Microsoft's PowerShell Gallery (powershellgallery.com).
The CurrentUser installs modules in a location that's accessible only to the current user of the computer (for example: $HOME\Documents\PowerShell\Modules):
Install-Module -Name Nebula.Automations -Scope CurrentUser
The AllUsers scope installs modules in a location that's accessible to all users of the computer ($env:ProgramFiles\PowerShell\Modules):
Install-Module -Name Nebula.Automations -Scope AllUsers
When no Scope is defined, the default is set based on the PowerShellGet version.
In PowerShellGet 1.x versions, the default is AllUsers, which requires elevation for install.
For PowerShellGet versions 2.0.0 and above in PowerShell 6 or higher:
- The default is CurrentUser, which doesn't require elevation for install.
- If you are running in an elevated session, the default is
AllUsers.
I recommend forcing the installation for AllUsers so that the entire system can call the module's functions, regardless of where the script to be executed is located. Needless to say, the final assessment is up to you, and the module also works in a user context (the user who will install the module, of course).
Update module
The same rules mentioned in the previous paragraph apply. You can therefore also associate the Scope parameter with the Update command.
Update-Module -Name Nebula.Automations
Cleaning of previous installations (optional)
The most up-to-date version of the module installed on your system will always be the one that PowerShell will prefer when you launch an Import-Module or call one of the Nebula.Automations functions.
In any case, if you want, you can always perform a complete cleanup of the installed versions and get the latest one (from PowerShell Gallery).
Uninstall-Module -Name Nebula.Automations -AllVersions -Force
Install-Module -Name Nebula.Automations -Scope CurrentUser -Force