Skip to content

Commit

Permalink
Module starter
Browse files Browse the repository at this point in the history
  • Loading branch information
PrzemyslawKlys committed Aug 23, 2022
0 parents commit cc21beb
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These are supported funding model platforms

github: PrzemyslawKlys
custom: https://paypal.me/PrzemyslawKlys
33 changes: 33 additions & 0 deletions GraphEssentials.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@{
AliasesToExport = @()
Author = 'Przemyslaw Klys'
CmdletsToExport = @()
CompanyName = 'Evotec'
CompatiblePSEditions = @('Desktop', 'Core')
Copyright = '(c) 2011 - 2022 Przemyslaw Klys @ Evotec. All rights reserved.'
Description = 'GraphEssentials is a PowerShell that help with Office 365 / Azure AD using mostly Graph'
FunctionsToExport = @('Get-MyApp', 'Get-MyAppCredentials', 'New-MyAppCredentials', 'Show-MyApp')
GUID = '75ef812f-6d8e-4898-81bb-8029e0560ef3'
ModuleVersion = '0.0.1'
PowerShellVersion = '5.1'
PrivateData = @{
PSData = @{
Tags = @('Windows')
ExternalModuleDependencies = @('Microsoft.PowerShell.Management', 'Microsoft.PowerShell.Security', 'Microsoft.PowerShell.Utility')
}
}
RequiredModules = @(@{
ModuleVersion = '0.0.238'
ModuleName = 'PSSharedGoods'
Guid = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe'
}, @{
ModuleVersion = '1.10.0'
ModuleName = 'Microsoft.Graph.Applications'
Guid = '467f54f2-44a8-4993-8e75-b96c3e443098'
}, @{
ModuleVersion = '0.0.177'
ModuleName = 'PSWriteHTML'
Guid = 'a7bdf640-f5cb-4acf-9de0-365b322d245c'
}, 'Microsoft.PowerShell.Management', 'Microsoft.PowerShell.Security', 'Microsoft.PowerShell.Utility')
RootModule = 'GraphEssentials.psm1'
}
59 changes: 59 additions & 0 deletions GraphEssentials.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#Get public and private function definition files.
$Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue -Recurse )
$Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue -Recurse )
$Classes = @( Get-ChildItem -Path $PSScriptRoot\Classes\*.ps1 -ErrorAction SilentlyContinue -Recurse )
$Enums = @( Get-ChildItem -Path $PSScriptRoot\Enums\*.ps1 -ErrorAction SilentlyContinue -Recurse )

$AssemblyFolders = Get-ChildItem -Path $PSScriptRoot\Lib -Directory -ErrorAction SilentlyContinue
$Assembly = @(
if ($AssemblyFolders.BaseName -contains 'Standard') {
@( Get-ChildItem -Path $PSScriptRoot\Lib\Standard\*.dll -ErrorAction SilentlyContinue -Recurse)
}
if ($PSEdition -eq 'Core') {
@( Get-ChildItem -Path $PSScriptRoot\Lib\Core\*.dll -ErrorAction SilentlyContinue -Recurse )
} else {
@( Get-ChildItem -Path $PSScriptRoot\Lib\Default\*.dll -ErrorAction SilentlyContinue -Recurse )
}
)
$FoundErrors = @(
Foreach ($Import in @($Assembly)) {
try {
Write-Verbose -Message $Import.FullName
Add-Type -Path $Import.Fullname -ErrorAction Stop
# }
} catch [System.Reflection.ReflectionTypeLoadException] {
Write-Warning "Processing $($Import.Name) Exception: $($_.Exception.Message)"
$LoaderExceptions = $($_.Exception.LoaderExceptions) | Sort-Object -Unique
foreach ($E in $LoaderExceptions) {
Write-Warning "Processing $($Import.Name) LoaderExceptions: $($E.Message)"
}
$true
#Write-Error -Message "StackTrace: $($_.Exception.StackTrace)"
} catch {
Write-Warning "Processing $($Import.Name) Exception: $($_.Exception.Message)"
$LoaderExceptions = $($_.Exception.LoaderExceptions) | Sort-Object -Unique
foreach ($E in $LoaderExceptions) {
Write-Warning "Processing $($Import.Name) LoaderExceptions: $($E.Message)"
}
$true
#Write-Error -Message "StackTrace: $($_.Exception.StackTrace)"
}
}
#Dot source the files
Foreach ($Import in @($Private + $Public + $Classes + $Enums)) {
Try {
. $Import.Fullname
} Catch {
Write-Error -Message "Failed to import functions from $($import.Fullname): $_"
$true
}
}
)

if ($FoundErrors.Count -gt 0) {
$ModuleName = (Get-ChildItem $PSScriptRoot\*.psd1).BaseName
Write-Warning "Importing module $ModuleName failed. Fix errors before continuing."
break
}

Export-ModuleMember -Function '*' -Alias '*'
21 changes: 21 additions & 0 deletions License
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Evotec

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
39 changes: 39 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<p align="center">
<a href="https://www.powershellgallery.com/packages/GraphEssentials"><img src="https://img.shields.io/powershellgallery/v/GraphEssentials.svg"></a>
<a href="https://www.powershellgallery.com/packages/GraphEssentials"><img src="https://img.shields.io/powershellgallery/vpre/GraphEssentials.svg?label=powershell%20gallery%20preview&colorB=yellow"></a>
<a href="https://github.com/EvotecIT/GraphEssentials"><img src="https://img.shields.io/github/license/EvotecIT/GraphEssentials.svg"></a>
</p>

<p align="center">
<a href="https://www.powershellgallery.com/packages/GraphEssentials"><img src="https://img.shields.io/powershellgallery/p/GraphEssentials.svg"></a>
<a href="https://github.com/EvotecIT/GraphEssentials"><img src="https://img.shields.io/github/languages/top/evotecit/GraphEssentials.svg"></a>
<a href="https://github.com/EvotecIT/GraphEssentials"><img src="https://img.shields.io/github/languages/code-size/evotecit/GraphEssentials.svg"></a>
<a href="https://www.powershellgallery.com/packages/GraphEssentials"><img src="https://img.shields.io/powershellgallery/dt/GraphEssentials.svg"></a>
</p>

<p align="center">
<a href="https://twitter.com/PrzemyslawKlys"><img src="https://img.shields.io/twitter/follow/PrzemyslawKlys.svg?label=Twitter%20%40PrzemyslawKlys&style=social"></a>
<a href="https://evotec.xyz/hub"><img src="https://img.shields.io/badge/Blog-evotec.xyz-2A6496.svg"></a>
<a href="https://www.linkedin.com/in/pklys"><img src="https://img.shields.io/badge/LinkedIn-pklys-0077B5.svg?logo=LinkedIn"></a>
</p>

# GraphEssentials PowerShell Module


## To install

```powershell
Install-Module -Name GraphEssentials -AllowClobber -Force
```

Force and AllowClobber aren't necessary, but they do skip errors in case some appear.

## And to update

```powershell
Update-Module -Name GraphEssentials
```

That's it. Whenever there's a new version, you run the command, and you can enjoy it. Remember that you may need to close, reopen PowerShell session if you have already used module before updating it.

**The essential thing** is if something works for you on production, keep using it till you test the new version on a test computer. I do changes that may not be big, but big enough that auto-update may break your code. For example, small rename to a parameter and your code stops working! Be responsible!

0 comments on commit cc21beb

Please sign in to comment.