mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-15 02:35:46 +00:00
add helper function Get-NetboxSlug.ps1
This commit is contained in:
parent
3abf2264d9
commit
9453383f34
1 changed files with 16 additions and 0 deletions
16
Functions/Helpers/Get-NetboxSlug.ps1
Normal file
16
Functions/Helpers/Get-NetboxSlug.ps1
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
function Get-NetboxSlug {
|
||||
param (
|
||||
[Parameter(ValueFromPipeline)]
|
||||
[string]$slug,
|
||||
|
||||
[uint16]$chars = 100
|
||||
)
|
||||
|
||||
process {
|
||||
return $slug -replace '[^\-.\w\s]', '' `
|
||||
-replace '[^a-zA-Z0-9-_ ]', '' `
|
||||
-replace '^[\s.]+|[\s.]+$', '' `
|
||||
-replace '[-.\s]+', '-' `
|
||||
| ForEach-Object { $_.ToLower().Substring(0, [Math]::Min($_.Length, $chars)) }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue