Skip to content

Commit

Permalink
Fix #38 - Missing $Resource definition in Set-NinjaOneOrganisationPol…
Browse files Browse the repository at this point in the history
…icies. Fixes for some other small bugs/issues also included.
  • Loading branch information
homotechsual committed May 24, 2024
1 parent 9b2fe92 commit 0d0ed08
Show file tree
Hide file tree
Showing 9 changed files with 665 additions and 618 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
indent_style = tab
indent_size = 1
8 changes: 5 additions & 3 deletions NinjaOne.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
}
],
"settings": {
"editor.tabSize": 4,
"editor.indentSize": "tabSize",
"editor.tabSize": 1,
"editor.detectIndentation": true,
"editor.autoIndent": "advanced",
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "modificationsIfAvailable",
"azure-pipelines.customSchemaFile": ".\\DevOps\\azurepipelines.schema.json",
Expand Down Expand Up @@ -48,8 +51,7 @@
{
"name": "PowerShell Attach Interactive Session Runspace",
"type": "PowerShell",
"request": "attach",
"processId": "current"
"request": "attach"
},
{
"name": "PowerShell: Launch Current File",
Expand Down
245 changes: 144 additions & 101 deletions PSScriptAnalyzerSettings.psd1
Original file line number Diff line number Diff line change
@@ -1,105 +1,148 @@
<#
.SYNOPSIS
Based on the PowerShell Script Analyzer (PSSA) presets.
.LINK
https://github.com/PowerShell/PSScriptAnalyzer/blob/master/Engine/Settings/
.SYNOPSIS
Based on the PowerShell Script Analyzer (PSSA) presets.
.LINK
https://github.com/PowerShell/PSScriptAnalyzer/blob/master/Engine/Settings/
#>
@{
Severity = @(
'Error',
'Warning',
'Information'
)
IncludeRules = @(
'PSAlignAssignmentStatement',
'PSAvoidAssignmentToAutomaticVariable',
'PSAvoidDefaultValueForMandatoryParameter',
'PSAvoidDefaultValueSwitchParameter',
'PSAvoidGlobalAliases',
'PSAvoidGlobalVars',
'PSAvoidUsingCmdletAliases',
'PSAvoidUsingComputerNameHardcoded',
'PSAvoidUsingConvertToSecureStringWithPlainText',
'PSAvoidUsingDoubleQuotesForConstantString',
'PSAvoidUsingEmptyCatchBlock',
'PSAvoidUsingInvokeExpression',
'PSAvoidUsingPlainTextForPassword',
'PSAvoidUsingPositionalParameters',
'PSAvoidUsingUserNameAndPasswordParams',
'PSAvoidUsingWMICmdlet',
'PSAvoidUsingWriteHost',
'PSAvoidUsingWMICmdlet',
'PSDSC*',
'PSMissingModuleManifestField',
'PSPlaceCloseBrace',
'PSPlaceOpenBrace',
'PSProvideCommentHelp',
'PSReservedCmdletChar',
'PSReservedParams',
'PSShouldProcess',
'PSUseApprovedVerbs',
'PSUseCmdletCorrectly',
'PSUseConsistentIndentation',
'PSUseConsistentWhitespace',
'PSUseCorrectCasing',
'PSUseDeclaredVarsMoreThanAssignments',
'PSUsePSCredentialType',
'PSUseShouldProcessForStateChangingFunctions',
#'PSUseSingularNouns',
'PSUseLowerCaseForBooleanVariables',
'PSUseLowerCaseForBuiltInFunctions',
'PSUseLowerCaseForParameters',
'PSUseTitleCaseForNonConstants',
'PSUseTitleCaseFunctionNames',
'PSUseTitleCaseVerbs',
'PSUseTitleCaseForCmdletParameters',
'PSUseTitleCaseForConstants'
)
Rules = @{
PSPlaceOpenBrace = @{
Enable = $true
OnSameLine = $true
NewLineAfter = $true
IgnoreOneLineBlock = $true
}

PSPlaceCloseBrace = @{
Enable = $true
NewLineAfter = $false
IgnoreOneLineBlock = $true
NoEmptyLineBefore = $false
}

PSUseConsistentIndentation = @{
Enable = $true
Kind = 'space'
PipelineIndentation = 'IncreaseIndentationForFirstPipeline'
IndentationSize = 4
}

PSUseConsistentWhitespace = @{
Enable = $true
CheckInnerBrace = $true
CheckOpenBrace = $true
CheckOpenParen = $true
CheckOperator = $true
CheckPipe = $true
CheckPipeForRedundantWhitespace = $false
CheckSeparator = $true
CheckParameter = $false
IgnoreAssignmentOperatorInsideHashTable = $true
}

PSUseCorrectCasing = @{
Enable = $true
}

PSAvoidUsingDoubleQuotesForConstantString = @{
Enable = $true
}

PSAlignAssignmentStatement = @{
Enable = $false
}
}
Severity = @(
'Error',
'Warning',
'Information'
)
IncludeRules = @(
'PSAlignAssignmentStatement',
'PSAvoidAssignmentToAutomaticVariable',
'PSAvoidDefaultValueForMandatoryParameter',
'PSAvoidDefaultValueSwitchParameter',
'PSAvoidGlobalAliases',
'PSAvoidGlobalFunctions',
'PSAvoidGlobalVars',
'PSAvoidInvokingEmptyMembers',
'PSAvoidNullOrEmptyHelpMessageAttribute',
'PSAvoidSemicolonsAsLineTerminators',
'PSAvoidShouldContinueWithoutForce',
'PSAvoidTrailingWhitespace',
'PSAvoidUsingBrokenHashAlgorithms',
'PSAvoidUsingCmdletAliases',
'PSAvoidUsingComputerNameHardcoded',
'PSAvoidUsingConvertToSecureStringWithPlainText',
'PSAvoidUsingDeprecatedManifestFields',
'PSAvoidUsingDoubleQuotesForConstantString',
'PSAvoidUsingEmptyCatchBlock',
'PSAvoidUsingInvokeExpression',
'PSAvoidUsingPlainTextForPassword',
'PSAvoidUsingPositionalParameters',
'PSAvoidUsingUserNameAndPasswordParams',
'PSAvoidUsingWMICmdlet',
'PSAvoidUsingWriteHost',
'PSDSC*',
'PSMisleadingBacktick',
'PSMissingModuleManifestField',
'PSPlaceCloseBrace',
'PSPlaceOpenBrace',
'PSPossibleIncorrectComparisonWithNull',
'PSPossibleIncorrectUsageOfAssignmentOperator',
'PSPossibleIncorrectUsageOfRedirectionOperator'
'PSProvideCommentHelp',
'PSReservedCmdletChar',
'PSReservedParams',
'PSReviewUnusedParameter',
'PSShouldProcess',
'PSUseApprovedVerbs',
'PSUseBOMForUnicodeEncodedFile',
'PSUseCmdletCorrectly',
'PSUseCompatibleCmdlets',
'PSUseCompatibleCommands',
'PSUseCompatibleSyntax',
'PSUseCompatibleTypes',
'PSUseConsistentIndentation',
'PSUseConsistentWhitespace',
'PSUseCorrectCasing',
'PSUseDeclaredVarsMoreThanAssignments',
'PSUseLiteralInitializerForHashtable',
'PSUseOutputTypeCorrectly',
'PSUseProcessBlockForPipelineCommand',
'PSUsePSCredentialType',
'PSUseShouldProcessForStateChangingFunctions',
'PSUseLowerCaseForBooleanVariables',
'PSUseLowerCaseForBuiltInFunctions',
'PSUseLowerCaseForParameters',
'PSUseSingularNouns',
'PSUseTitleCaseForCmdletParameters',
'PSUseTitleCaseForConstants',
'PSUseTitleCaseForNonConstants',
'PSUseTitleCaseFunctionNames',
'PSUseTitleCaseVerbs'
)
Rules = @{
PSAlignAssignmentStatement = @{
Enable = $false
}
PSPlaceCloseBrace = @{
Enable = $true
NewLineAfter = $false
IgnoreOneLineBlock = $true
NoEmptyLineBefore = $false
}
PSPlaceOpenBrace = @{
Enable = $true
OnSameLine = $true
NewLineAfter = $true
IgnoreOneLineBlock = $true
}
PSReviewUnusedParameter = @{
Enable = $true
CommandsToTraverse = @(
'New-NinjaOneQuery'
)
}
PSUseCompatibleCmdlets = @{
Enable = $true
Compatibility = @(
'desktop-5.1.14393.206-windows',
'core-6.1.0-windows',
'core-6.1.0-linux',
'core-6.1.0-linux-arm'
'core-6.1.0-macos'
)
}
PSUseCompatibleCommands = @{
Enable = $false
}
PSUseCompatibleSyntax = @{
Enable = $true
TargetVersions = @(
'5.1',
'6.0',
'7.0'
)
}
PSUseConsistentIndentation = @{
Enable = $true
Kind = 'tab'
PipelineIndentation = 'IncreaseIndentationForFirstPipeline'
}
PSUseConsistentWhitespace = @{
Enable = $true
CheckInnerBrace = $true
CheckOpenBrace = $true
CheckOpenParen = $true
CheckOperator = $true
CheckPipe = $true
CheckPipeForRedundantWhitespace = $true
CheckSeparator = $true
CheckParameter = $true
IgnoreAssignmentOperatorInsideHashTable = $true
}
PSUseCorrectCasing = @{
Enable = $true
}
PSUseSingularNouns = @{
Enable = $false
}
PSAvoidUsingDoubleQuotesForConstantString = @{
Enable = $true
}
}
}
2 changes: 1 addition & 1 deletion Source/Private/ConvertTo-UnixEpoch.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function ConvertTo-UnixEpoch {
if ($DateTime -is [String]) {
$DateTime = [DateTime]::Parse($DateTime)
} elseif ($DateTime -is [Int]) {
(Get-Date 01.01.1970).AddSeconds($unixTimeStamp)
(Get-Date 01.01.1970).AddSeconds($unixTimeStamp)
} elseif ($DateTime -is [DateTime]) {
$DateTime = $DateTime
} else {
Expand Down
Loading

0 comments on commit 0d0ed08

Please sign in to comment.