diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml index d1c801b..fdb8997 100644 --- a/.github/workflows/versioning.yml +++ b/.github/workflows/versioning.yml @@ -38,7 +38,6 @@ jobs: with: commit_message: Bumping release to ${{ steps.buildUpdate.outputs.v }} branch: release - push_options: '--force' Minor: if: startsWith(github.head_ref, 'minor/') && github.event.pull_request.merged == true outputs: @@ -64,7 +63,6 @@ jobs: with: commit_message: Bumping release to ${{ steps.buildUpdate.outputs.v }} branch: release - push_options: '--force' Major: if: startsWith(github.head_ref, 'major/') && github.event.pull_request.merged == true outputs: @@ -89,5 +87,4 @@ jobs: uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: Bumping release to ${{ steps.buildUpdate.outputs.v }} - branch: release - push_options: '--force' \ No newline at end of file + branch: release \ No newline at end of file diff --git a/docs/function-documentation/Add-VerkadaAccessBadgeToUser.md b/docs/function-documentation/Add-VerkadaAccessBadgeToUser.md deleted file mode 100644 index 45bed1a..0000000 --- a/docs/function-documentation/Add-VerkadaAccessBadgeToUser.md +++ /dev/null @@ -1,217 +0,0 @@ ---- -external help file: verkadaModule-help.xml -Module Name: verkadaModule -online version: https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessBadgeToUser.md -schema: 2.0.0 ---- - -# Add-VerkadaAccessBadgeToUser - -## SYNOPSIS -Adds a badge to an Access User in an organization - -## SYNTAX - -### cardNumber (Default) -``` -Add-VerkadaAccessBadgeToUser [-org_id ] -userId -cardType -cardNumber - [-facilityCode ] [-x_verkada_token ] [-x_verkada_auth ] [-threads ] - [-ProgressAction ] [] -``` - -### cardNumberHex -``` -Add-VerkadaAccessBadgeToUser [-org_id ] -userId -cardType -cardNumberHex - [-facilityCode ] [-x_verkada_token ] [-x_verkada_auth ] [-threads ] - [-ProgressAction ] [] -``` - -## DESCRIPTION -This function is used to add a badge to a Verkada access user. -The org_id and reqired tokens can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands. - -## EXAMPLES - -### EXAMPLE 1 -``` -Add-VerkadaAccessBadgeToUser -userId 'gjg547-uuid-of-user' -cardType 'HID' -facilityCode 111 -cardNumber 55555 -This will add a badge in the HID format with facility code 111 and card number 55555 to the user specified. The org_id and tokens will be populated from the cached created by Connect-Verkada. -``` - -### EXAMPLE 2 -``` -Add-VerkadaAccessBadgeToUser -userId 'gjg547-uuid-of-user' -cardType 'HID' -facilityCode 111 -cardNumber 55555 -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_token 'a366ef47-2c20-4d35-a90a-10fd2aee113a' -x_verkada_auth 'auth-token-uuid-dscsdc' -This will add a badge in the HID format with facility code 111 and card number 55555 to the user specified. The org_id and tokens are submitted as parameters in the call. -``` - -### EXAMPLE 3 -``` -Import-Csv ./myUserBadges.csv | Add-VerkadaAccessBadgeToUser -This will add a badge for every row in the csv file which contains userId, cardType, cardNumber(or cardNumberHex), and facilityCode(optional). The org_id and tokens will be populated from the cached created by Connect-Verkada. -``` - -## PARAMETERS - -### -org_id -The UUID of the organization the user belongs to - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: $Global:verkadaConnection.org_id -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -userId -The UUID of the user the badge is being added to - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -cardType -The card type of the card being added - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -cardNumber -The card number of the card being added - -```yaml -Type: String -Parameter Sets: cardNumber -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -cardNumberHex -The card Number Hex of the card being added - -```yaml -Type: String -Parameter Sets: cardNumberHex -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -facilityCode -The facility code of the card being added - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -x_verkada_token -The Verkada(CSRF) token of the user running the command - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: $Global:verkadaConnection.csrfToken -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -x_verkada_auth -The Verkada Auth(session auth) token of the user running the command - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: $Global:verkadaConnection.userToken -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -threads -Number of threads allowed to multi-thread the task - -```yaml -Type: Int32 -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS - -[https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessBadgeToUser.md](https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessBadgeToUser.md) - diff --git a/docs/function-documentation/Add-VerkadaAccessUser.md b/docs/function-documentation/Add-VerkadaAccessUser.md deleted file mode 100644 index 0d404e8..0000000 --- a/docs/function-documentation/Add-VerkadaAccessUser.md +++ /dev/null @@ -1,478 +0,0 @@ ---- -external help file: verkadaModule-help.xml -Module Name: verkadaModule -online version: https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessUser.md -schema: 2.0.0 ---- - -# Add-VerkadaAccessUser - -## SYNOPSIS -Adds an Access User in an organization - -## SYNTAX - -``` -Add-VerkadaAccessUser [[-org_id] ] [[-email] ] [[-firstName] ] [[-lastName] ] - [[-x_verkada_token] ] [[-x_verkada_auth] ] [[-phone] ] [[-role] ] - [[-start] ] [[-expiration] ] [[-sendInviteEmail] ] [[-cardType] ] - [[-cardNumber] ] [[-cardNumberHex] ] [[-facilityCode] ] [[-pinCode] ] - [[-groupId] ] [[-groupName] ] [[-employeeId] ] [[-employeeTitle] ] - [[-department] ] [[-departmentId] ] [[-companyName] ] [[-usr] ] - [[-threads] ] [-ProgressAction ] [] -``` - -## DESCRIPTION -This function is used to add a Verkaka Access user or users to a Verkada Command Organization. -As part of the user creation you can optionally add a badge and/or add the user to groups. -The org_id and reqired tokens can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands. - -## EXAMPLES - -### EXAMPLE 1 -``` -Add-VerkadaAccessUser -firstName 'New' -lastName 'User' -This will add the access user with the name "New User". The org_id and tokens will be populated from the cached created by Connect-Verkada. -``` - -### EXAMPLE 2 -``` -Add-VerkadaAccessUser -firstName 'New' -lastName 'User' -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_token 'a366ef47-2c20-4d35-a90a-10fd2aee113a' -x_verkada_auth 'auth-token-uuid-dscsdc' -usr 'a099bfe6-34ff-4976-9d53-ac68342d2b60' -This will add the access user with the name "New User". The org_id and tokens are submitted as parameters in the call. -``` - -### EXAMPLE 3 -``` -Add-VerkadaAccessUser -firstName 'New' -lastName 'User' -email 'newUser@contoso.com' -This will add the access user with the name "New User" and email newUser@contoso.com. The org_id and tokens will be populated from the cached created by Connect-Verkada. -``` - -### EXAMPLE 4 -``` -Add-VerkadaAccessUser -email 'newUser@contoso.com' -This will add the access user with the email newUser@contoso.com. The org_id and tokens will be populated from the cached created by Connect-Verkada. -``` - -### EXAMPLE 5 -``` -Add-VerkadaAccessUser -firstName 'New' -lastName 'User' -email 'newUser@contoso.com -department 'sales' -departmentId 'US-Sales' -employeeId '12345' -employeeTitle 'The Closer' -companyName 'Contoso' -This will add the access user with the name "New User" and email newUser@contoso.com in department defined as sales with departmnetId of US-Sales with the appropriate employeeID, Title, and Company. The org_id and tokens will be populated from the cached created by Connect-Verkada. -``` - -### EXAMPLE 6 -``` -Add-VerkadaAccessUser -firstName 'New' -lastName 'User' -email 'newUser@contoso.com' -cardType 'HID' -facilityCode 111 -cardNumber 55555 -pinCode '12345' -This will add the access user with the name "New User" and email newUser@contoso.com with an HID badge 111-55555 and a pin code of 12345. The org_id and tokens will be populated from the cached created by Connect-Verkada. -``` - -### EXAMPLE 7 -``` -Add-VerkadaAccessUser -firstName 'New' -lastName 'User' -email 'newUser@contoso.com' -cardType 'HID' -facilityCode 111 -cardNumber 55555 -groupId 'df76sd-dsc-group1','dsf987-daf-group2' -This will add the access user with the name "New User" and email newUser@contoso.com with an HID badge 111-55555 and in groups df76sd-dsc-group1 and dsf987-daf-group2. The org_id and tokens will be populated from the cached created by Connect-Verkada. -``` - -## PARAMETERS - -### -org_id -The UUID of the organization the user belongs to - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: $Global:verkadaConnection.org_id -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -email -The email address of the user being added - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -firstName -The first name of the user being added - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 3 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -lastName -The last name of the user being added - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 4 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -x_verkada_token -The Verkada(CSRF) token of the user running the command - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 5 -Default value: $Global:verkadaConnection.csrfToken -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -x_verkada_auth -The Verkada Auth(session auth) token of the user running the command - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 6 -Default value: $Global:verkadaConnection.userToken -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -phone -The phone number of the user being added - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 7 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -role -The role of the user being added. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 8 -Default value: ORG_MEMBER -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -start -Start date/time of the user being added - -```yaml -Type: DateTime -Parameter Sets: (All) -Aliases: - -Required: False -Position: 9 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -expiration -End date/time of the user being added - -```yaml -Type: DateTime -Parameter Sets: (All) -Aliases: - -Required: False -Position: 10 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -sendInviteEmail -Boolean on whether to send invite email to newly created user - -```yaml -Type: Boolean -Parameter Sets: (All) -Aliases: - -Required: False -Position: 11 -Default value: False -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -cardType -The card type of the card being added - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 12 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -cardNumber -The card number of the card being added (Mutually exclusive with CardHex) - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 13 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -cardNumberHex -The card Number Hex of the card being added (Mutually exclusive with Card Number) - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 14 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -facilityCode -The facility code of the card being added - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 15 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -pinCode -The pin code being added - -```yaml -Type: String -Parameter Sets: (All) -Aliases: pin - -Required: False -Position: 16 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -groupId -The UUID of the group or groups the user should be added to on creation - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: 17 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -groupName -The name of the group or groups the user should be added to on creation(not currently implemented) - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: 18 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -employeeId -The employee ID of the user - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 19 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -employeeTitle -The title of the user - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 20 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -department -The department of the user - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 21 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -departmentId -The departmentId of the user - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 22 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -companyName -The company name of the user - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 23 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -usr -The UUID of the user account making the request - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 24 -Default value: $Global:verkadaConnection.usr -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -threads -Number of threads allowed to multi-thread the task - -```yaml -Type: Int32 -Parameter Sets: (All) -Aliases: - -Required: False -Position: 25 -Default value: 4 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS - -[https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessUser.md](https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessUser.md) - diff --git a/docs/function-documentation/Add-VerkadaAccessUserPin.md b/docs/function-documentation/Add-VerkadaAccessUserPin.md deleted file mode 100644 index 4c0999d..0000000 --- a/docs/function-documentation/Add-VerkadaAccessUserPin.md +++ /dev/null @@ -1,163 +0,0 @@ ---- -external help file: verkadaModule-help.xml -Module Name: verkadaModule -online version: https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessUserPin.md -schema: 2.0.0 ---- - -# Add-VerkadaAccessUserPin - -## SYNOPSIS -Adds a Pin code to an Access User in an organization - -## SYNTAX - -``` -Add-VerkadaAccessUserPin [-org_id ] [-userId] [-pinCode] [-x_verkada_token ] - [-x_verkada_auth ] [-threads ] [-ProgressAction ] [] -``` - -## DESCRIPTION -This function is used to add a Pin code to a Verkada access user. -The org_id and reqired tokens can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands. - -## EXAMPLES - -### EXAMPLE 1 -``` -Add-VerkadaAccessUserPin -userId 'gjg547-uuid-of-user' -pinCode '12345' -This will add a pin code of 12345 to the user specified. The org_id and tokens will be populated from the cached created by Connect-Verkada. -``` - -### EXAMPLE 2 -``` -Add-VerkadaAccessUserPin -userId 'gjg547-uuid-of-user' -pinCode '12345' -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_token 'a366ef47-2c20-4d35-a90a-10fd2aee113a' -x_verkada_auth 'auth-token-uuid-dscsdc' -This will add a pin code of 12345 to the user specified. The org_id and tokens are submitted as parameters in the call. -``` - -### EXAMPLE 3 -``` -Import-Csv ./myUserPins.csv | Add-VerkadaAccessUserPin -This will add a Pin code for every row in the csv file which contains userId, and pinCode. The org_id and tokens will be populated from the cached created by Connect-Verkada. -``` - -## PARAMETERS - -### -org_id -The UUID of the organization the user belongs to - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: $Global:verkadaConnection.org_id -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -userId -The UUID of the user the pin code is being added to - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -pinCode -The pin code being added - -```yaml -Type: String -Parameter Sets: (All) -Aliases: pin - -Required: True -Position: 2 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -x_verkada_token -The Verkada(CSRF) token of the user running the command - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: $Global:verkadaConnection.csrfToken -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -x_verkada_auth -The Verkada Auth(session auth) token of the user running the command - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: $Global:verkadaConnection.userToken -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -threads -Number of threads allowed to multi-thread the task - -```yaml -Type: Int32 -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS - -[https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessUserPin.md](https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessUserPin.md) - diff --git a/docs/function-documentation/Add-VerkadaAccessUserToGroup.md b/docs/function-documentation/Add-VerkadaAccessUserToGroup.md deleted file mode 100644 index 090d5f6..0000000 --- a/docs/function-documentation/Add-VerkadaAccessUserToGroup.md +++ /dev/null @@ -1,187 +0,0 @@ ---- -external help file: verkadaModule-help.xml -Module Name: verkadaModule -online version: https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessUserToGroup.md -schema: 2.0.0 ---- - -# Add-VerkadaAccessUserToGroup - -## SYNOPSIS -Adds an Access User to an Access Group in an organization - -## SYNTAX - -### email (Default) -``` -Add-VerkadaAccessUserToGroup [-org_id ] -userId [-x_verkada_token ] - [-x_verkada_auth ] [-threads ] [-ProgressAction ] [] -``` - -### groupId -``` -Add-VerkadaAccessUserToGroup [-org_id ] -userId -groupId - [-x_verkada_token ] [-x_verkada_auth ] [-threads ] [-ProgressAction ] - [] -``` - -### groupName -``` -Add-VerkadaAccessUserToGroup [-org_id ] -userId -groupName - [-x_verkada_token ] [-x_verkada_auth ] [-threads ] [-ProgressAction ] - [] -``` - -## DESCRIPTION -This function is used to add a Verkada Access user to a group or groups. -The org_id and reqired tokens can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands. - -## EXAMPLES - -### EXAMPLE 1 -``` -Add-VerkadaAccessUserToGroup -userid 'dcscsdc-dsc-user1' -groupId 'df76sd-dsc-group1','dsf987-daf-group2' -This will add the userid dcscsdc-dsc-user1 to access groups df76sd-dsc-group1 and dsf987-daf-group2. The org_id and tokens will be populated from the cached created by Connect-Verkada. -``` - -### EXAMPLE 2 -``` -Add-VerkadaAccessUserToGroup -userid 'dcscsdc-dsc-user1' -groupId 'df76sd-dsc-group1','dsf987-daf-group2' -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_token 'a366ef47-2c20-4d35-a90a-10fd2aee113a' -x_verkada_auth 'auth-token-uuid-dscsdc' -This will add the userid dcscsdc-dsc-user1 to access groups df76sd-dsc-group1 and dsf987-daf-group2. The org_id and tokens are submitted as parameters in the call. -``` - -## PARAMETERS - -### -org_id -The UUID of the organization the user belongs to - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: $Global:verkadaConnection.org_id -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -userId -The UUID of the user the badge is being added to - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -groupId -The UUID of the group or groups the user should be added to - -```yaml -Type: String[] -Parameter Sets: groupId -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -groupName -The name of the group or groups the user should be added to on creation(not currently implemented) - -```yaml -Type: String[] -Parameter Sets: groupName -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -x_verkada_token -The Verkada(CSRF) token of the user running the command - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: $Global:verkadaConnection.csrfToken -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -x_verkada_auth -The Verkada Auth(session auth) token of the user running the command - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: $Global:verkadaConnection.userToken -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -threads -Number of threads allowed to multi-thread the task - -```yaml -Type: Int32 -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS - -[https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessUserToGroup.md](https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessUserToGroup.md) - diff --git a/docs/function-documentation/Export-VerkadaAccessUserProfilePicture.md b/docs/function-documentation/Export-VerkadaAccessUserProfilePicture.md deleted file mode 100644 index 115f863..0000000 --- a/docs/function-documentation/Export-VerkadaAccessUserProfilePicture.md +++ /dev/null @@ -1,164 +0,0 @@ ---- -external help file: verkadaModule-help.xml -Module Name: verkadaModule -online version: https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Export-VerkadaAccessUserProfilePicture.md -schema: 2.0.0 ---- - -# Export-VerkadaAccessUserProfilePicture - -## SYNOPSIS -Downloads a copy of the current Verkada Access profile picture. - -## SYNTAX - -``` -Export-VerkadaAccessUserProfilePicture [[-userId] ] [[-outPath] ] [[-org_id] ] - [[-x_verkada_token] ] [[-x_verkada_auth] ] [[-usr] ] - [-ProgressAction ] [] -``` - -## DESCRIPTION -This will download the Access user's, specified by the userId, current profile picture. -The org_id and reqired tokens can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands. - -## EXAMPLES - -### EXAMPLE 1 -``` -Export-VerkadaAccessUserProfilePicture -userId '801c9551-b04c-4293-84ad-b0a6aa0588b3' -outPath './MyProfilePics' -This downloads the Access user's, with userId 801c9551-b04c-4293-84ad-b0a6aa0588b3, picture to ./MyProfilePics/801c9551-b04c-4293-84ad-b0a6aa0588b3.jpg. The org_id and tokens will be populated from the cached created by Connect-Verkada. -``` - -### EXAMPLE 2 -``` -Find-VerkadaUserId -email 'some.user@contoso.com' | Export-VerkadaAccessUserProfilePicture -This downloads the Access user's, with email some.user@contoso.com, picture to ./MyProfilePics/801c9551-b04c-4293-84ad-b0a6aa0588b3.jpg. The org_id and tokens will be populated from the cached created by Connect-Verkada. -``` - -### EXAMPLE 3 -``` -Export-VerkadaAccessUserProfilePicture -userId '801c9551-b04c-4293-84ad-b0a6aa0588b3' -outPath './MyProfilePics' -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_token 'a366ef47-2c20-4d35-a90a-10fd2aee113a' -x_verkada_auth 'auth-token-uuid-dscsdc' -usr 'a099bfe6-34ff-4976-9d53-ac68342d2b60' -This downloads the Access user's, with userId 801c9551-b04c-4293-84ad-b0a6aa0588b3, picture to ./MyProfilePics/801c9551-b04c-4293-84ad-b0a6aa0588b3.jpg. The org_id and tokens are submitted as parameters in the call. -``` - -## PARAMETERS - -### -userId -The UUID of the user - -```yaml -Type: String -Parameter Sets: (All) -Aliases: user_id - -Required: False -Position: 1 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -outPath -This is the path the picture/s will attempt to be saved to - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: ./ -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -org_id -The UUID of the organization the user belongs to - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 3 -Default value: $Global:verkadaConnection.org_id -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -x_verkada_token -The Verkada(CSRF) token of the user running the command - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 4 -Default value: $Global:verkadaConnection.csrfToken -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -x_verkada_auth -The Verkada Auth(session auth) token of the user running the command - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 5 -Default value: $Global:verkadaConnection.userToken -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -usr -The UUID of the user account making the request - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 6 -Default value: $Global:verkadaConnection.usr -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS - -[https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Export-VerkadaAccessUserProfilePicture.md](https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Export-VerkadaAccessUserProfilePicture.md) - diff --git a/docs/function-documentation/Test-VerkadaAccessProfilePictureUrl.md b/docs/function-documentation/Test-VerkadaAccessProfilePictureUrl.md deleted file mode 100644 index 287b99d..0000000 --- a/docs/function-documentation/Test-VerkadaAccessProfilePictureUrl.md +++ /dev/null @@ -1,189 +0,0 @@ ---- -external help file: verkadaModule-help.xml -Module Name: verkadaModule -online version: https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Test-VerkadaAccessProfilePictureUrl.md -schema: 2.0.0 ---- - -# Test-VerkadaAccessProfilePictureUrl - -## SYNOPSIS -Tests to see if the user profile picture URL is valid; i.e. -does the user have a profile picture. - -## SYNTAX - -``` -Test-VerkadaAccessProfilePictureUrl [[-userId] ] [[-email] ] [[-firstName] ] - [[-lastName] ] [[-org_id] ] [[-x_verkada_token] ] [[-x_verkada_auth] ] - [[-usr] ] [-ProgressAction ] [] -``` - -## DESCRIPTION -This function will test to see if the user profile picture url returns a 200 or a 404 to determine if the user specified has a profile picture. -The org_id and reqired tokens can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands. - -## EXAMPLES - -### EXAMPLE 1 -``` -Test-VerkadaAccessProfilePictureUrl -userId '801c9551-b04c-4293-84ad-b0a6aa0588b3' -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_token 'a366ef47-2c20-4d35-a90a-10fd2aee113a' -x_verkada_auth 'auth-token-uuid-dscsdc' -usr 'a099bfe6-34ff-4976-9d53-ac68342d2b60' -This will test to see if a profile picture for the user with userId 801c9551-b04c-4293-84ad-b0a6aa0588b3 exists. The org_id and tokens are submitted as parameters in the call. -``` - -### EXAMPLE 2 -``` -Read-VerkadaCommandUsers | Test-VerkadaAccessProfilePictureUrl -This will test to see if a profile picture for all the users in a organization exists. The org_id and tokens will be populated from the cached created by Connect-Verkada. -``` - -## PARAMETERS - -### -userId -The UUID of the user - -```yaml -Type: String -Parameter Sets: (All) -Aliases: user_id - -Required: False -Position: 1 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -email -The email address of the user - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -firstName -The first name of the user - -```yaml -Type: String -Parameter Sets: (All) -Aliases: first_name - -Required: False -Position: 3 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -lastName -The last name of the user - -```yaml -Type: String -Parameter Sets: (All) -Aliases: last_name - -Required: False -Position: 4 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -org_id -The UUID of the organization the user belongs to - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 5 -Default value: $Global:verkadaConnection.org_id -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -x_verkada_token -The Verkada(CSRF) token of the user running the command - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 6 -Default value: $Global:verkadaConnection.csrfToken -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -x_verkada_auth -The Verkada Auth(session auth) token of the user running the command - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 7 -Default value: $Global:verkadaConnection.userToken -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -usr -The UUID of the user account making the request - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 8 -Default value: $Global:verkadaConnection.usr -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS - -[https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Test-VerkadaAccessProfilePictureUrl.md](https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Test-VerkadaAccessProfilePictureUrl.md) - diff --git a/verkadaModule/Private/Invoke-VerkadaRestMethod.ps1 b/verkadaModule/Private/Invoke-VerkadaRestMethod.ps1 index d48d22f..b55e206 100644 --- a/verkadaModule/Private/Invoke-VerkadaRestMethod.ps1 +++ b/verkadaModule/Private/Invoke-VerkadaRestMethod.ps1 @@ -63,7 +63,10 @@ function Invoke-VerkadaRestMethod [string]$x_verkada_auth, #Switch to indicate username/password auth is required [Parameter(ParameterSetName = 'UnPwd')] - [Switch]$UnPwd + [Switch]$UnPwd, + #This is the path output files will attempt to saved to + [Parameter()] + [string]$outFile ) Process { @@ -105,8 +108,19 @@ function Invoke-VerkadaRestMethod $loop = $false $rt = 0 do { + $params = @{ + 'uri' = $uri + 'Body' = $body + 'ContentType' = 'application/json' + 'Method' = $method + 'Headers' = $headers + 'TimeoutSec' = 5 + 'StatusCodeVariable' = 'resCode' + 'SkipHttpErrorCheck' = $true + } + if (!([string]::IsNullOrEmpty($outFile))){$params.outFile = $outFile} try { - $response = Invoke-RestMethod -Uri $uri -Body $body -Headers $headers -ContentType 'application/json' -TimeoutSec 5 -SkipHttpErrorCheck -StatusCodeVariable resCode + $response = Invoke-RestMethod @params $records += $response.($propertyName) $page_token = $response.next_page_token @@ -169,8 +183,19 @@ function Invoke-VerkadaRestMethod $loop = $false $rt = 0 do { + $params = @{ + 'uri' = $uri + 'Body' = $body + 'ContentType' = 'application/json' + 'Method' = $method + 'Headers' = $headers + 'TimeoutSec' = 5 + 'StatusCodeVariable' = 'resCode' + 'SkipHttpErrorCheck' = $true + } + if (!([string]::IsNullOrEmpty($outFile))){$params.outFile = $outFile} try { - $response = Invoke-RestMethod -Uri $uri -Body $body -Headers $headers -Method $method -ContentType 'application/json' -TimeoutSec 5 -SkipHttpErrorCheck -StatusCodeVariable resCode + $response = Invoke-RestMethod @params switch ($resCode) { {($_ -eq 200) -or ($_ -eq 201)} { diff --git a/verkadaModule/Public/Add-VerkadaAccessBadgeToUser.ps1 b/verkadaModule/Public/Add-VerkadaAccessBadgeToUser.ps1 deleted file mode 100644 index cdcaa73..0000000 --- a/verkadaModule/Public/Add-VerkadaAccessBadgeToUser.ps1 +++ /dev/null @@ -1,102 +0,0 @@ -function Add-VerkadaAccessBadgeToUser -{ - <# - .SYNOPSIS - Adds a badge to an Access User in an organization - - .DESCRIPTION - This function is used to add a badge to a Verkada access user. - The org_id and reqired tokens can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands. - - .LINK - https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessBadgeToUser.md - - .EXAMPLE - Add-VerkadaAccessBadgeToUser -userId 'gjg547-uuid-of-user' -cardType 'HID' -facilityCode 111 -cardNumber 55555 - This will add a badge in the HID format with facility code 111 and card number 55555 to the user specified. The org_id and tokens will be populated from the cached created by Connect-Verkada. - - .EXAMPLE - Add-VerkadaAccessBadgeToUser -userId 'gjg547-uuid-of-user' -cardType 'HID' -facilityCode 111 -cardNumber 55555 -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_token 'a366ef47-2c20-4d35-a90a-10fd2aee113a' -x_verkada_auth 'auth-token-uuid-dscsdc' - This will add a badge in the HID format with facility code 111 and card number 55555 to the user specified. The org_id and tokens are submitted as parameters in the call. - - .EXAMPLE - Import-Csv ./myUserBadges.csv | Add-VerkadaAccessBadgeToUser - This will add a badge for every row in the csv file which contains userId, cardType, cardNumber(or cardNumberHex), and facilityCode(optional). The org_id and tokens will be populated from the cached created by Connect-Verkada. - #> - - [CmdletBinding(PositionalBinding = $true, DefaultParameterSetName = 'cardNumber')] - Param( - #The UUID of the organization the user belongs to - [Parameter(ValueFromPipelineByPropertyName = $true)] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [String]$org_id = $Global:verkadaConnection.org_id, - #The UUID of the user the badge is being added to - [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [String]$userId, - #The card type of the card being added - [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] - [ValidateSet('HID','HID37wFacilityCode','HID37woFacilityCode','HID34','CasiRusco','Corporate1000_35','Corporate1000_48','iClass','DESFire','VerkadaDESFire','MiFareClassic1K_CSN','MiFareClassic4K_CSN','MDCCustom_64','HID36Keyscan','HID33DSX','HID33RS2','HID36Simplex','Cansec37','CreditCardBin','KantechXSF','Schlage34','Schlage37x','RBH50','GProxII36','AMAG32','Securitas37','Kastle32','PointGuardMDI37','Blackboard64','IDm64bit','Continental36','AWID34','HIDInfinity37')] - [String]$cardType, - #The card number of the card being added - [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'cardNumber')] - [String]$cardNumber, - #The card Number Hex of the card being added - [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'cardNumberHex')] - [String]$cardNumberHex, - #The facility code of the card being added - [Parameter(ValueFromPipelineByPropertyName = $true)] - [String]$facilityCode, - #The Verkada(CSRF) token of the user running the command - [Parameter()] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [string]$x_verkada_token = $Global:verkadaConnection.csrfToken, - #The Verkada Auth(session auth) token of the user running the command - [Parameter()] - [ValidateNotNullOrEmpty()] - [string]$x_verkada_auth = $Global:verkadaConnection.userToken, - #Number of threads allowed to multi-thread the task - [Parameter()] - [ValidateRange(1,4)] - [int]$threads=$null - ) - - Begin { - #parameter validation - if ([string]::IsNullOrEmpty($org_id)) {throw "org_id is missing but is required!"} - if ([string]::IsNullOrEmpty($x_verkada_token)) {throw "x_verkada_token is missing but is required!"} - if ([string]::IsNullOrEmpty($x_verkada_auth)) {throw "x_verkada_auth is missing but is required!"} - - $url = "https://vcerberus.command.verkada.com/user/access_card/add" - } #end begin - - Process { - $body_params = @{ - "userId" = $userId - "organizationId" = $org_id - "cardType" = $cardType - } - $body_params.cardParams = @{} - if (!([string]::IsNullOrEmpty($cardNumber))){$body_params.cardParams.cardNumber = $cardNumber} - if (!([string]::IsNullOrEmpty($cardNumberHex))){$body_params.cardParams.cardNumberHex = $cardNumberHex} - if (!([string]::IsNullOrEmpty($facilityCode))){$body_params.cardParams.facilityCode = $facilityCode} - - try { - Invoke-VerkadaRestMethod $url $org_id $body_params -x_verkada_token $x_verkada_token -x_verkada_auth $x_verkada_auth -Method 'POST' -UnPwd - } - catch [Microsoft.PowerShell.Commands.HttpResponseException] { - $err = $_.ErrorDetails | ConvertFrom-Json - $errorMes = $_ | Convertto-Json -WarningAction SilentlyContinue - $err | Add-Member -NotePropertyName StatusCode -NotePropertyValue (($errorMes | ConvertFrom-Json -Depth 100 -WarningAction SilentlyContinue).Exception.Response.StatusCode) -Force - - throw "$($err.StatusCode) - $($err.message)" - } - } #end process - - End { - - } #end end -} #end function \ No newline at end of file diff --git a/verkadaModule/Public/Add-VerkadaAccessUser.ps1 b/verkadaModule/Public/Add-VerkadaAccessUser.ps1 deleted file mode 100644 index 9aed2fd..0000000 --- a/verkadaModule/Public/Add-VerkadaAccessUser.ps1 +++ /dev/null @@ -1,336 +0,0 @@ -function Add-VerkadaAccessUser -{ - <# - .SYNOPSIS - Adds an Access User in an organization - - .DESCRIPTION - This function is used to add a Verkaka Access user or users to a Verkada Command Organization. As part of the user creation you can optionally add a badge and/or add the user to groups. - The org_id and reqired tokens can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands. - - .LINK - https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessUser.md - - .EXAMPLE - Add-VerkadaAccessUser -firstName 'New' -lastName 'User' - This will add the access user with the name "New User". The org_id and tokens will be populated from the cached created by Connect-Verkada. - - .EXAMPLE - Add-VerkadaAccessUser -firstName 'New' -lastName 'User' -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_token 'a366ef47-2c20-4d35-a90a-10fd2aee113a' -x_verkada_auth 'auth-token-uuid-dscsdc' -usr 'a099bfe6-34ff-4976-9d53-ac68342d2b60' - This will add the access user with the name "New User". The org_id and tokens are submitted as parameters in the call. - - .EXAMPLE - Add-VerkadaAccessUser -firstName 'New' -lastName 'User' -email 'newUser@contoso.com' - This will add the access user with the name "New User" and email newUser@contoso.com. The org_id and tokens will be populated from the cached created by Connect-Verkada. - - .EXAMPLE - Add-VerkadaAccessUser -email 'newUser@contoso.com' - This will add the access user with the email newUser@contoso.com. The org_id and tokens will be populated from the cached created by Connect-Verkada. - - .EXAMPLE - Add-VerkadaAccessUser -firstName 'New' -lastName 'User' -email 'newUser@contoso.com -department 'sales' -departmentId 'US-Sales' -employeeId '12345' -employeeTitle 'The Closer' -companyName 'Contoso' - This will add the access user with the name "New User" and email newUser@contoso.com in department defined as sales with departmnetId of US-Sales with the appropriate employeeID, Title, and Company. The org_id and tokens will be populated from the cached created by Connect-Verkada. - - .EXAMPLE - Add-VerkadaAccessUser -firstName 'New' -lastName 'User' -email 'newUser@contoso.com' -cardType 'HID' -facilityCode 111 -cardNumber 55555 -pinCode '12345' - This will add the access user with the name "New User" and email newUser@contoso.com with an HID badge 111-55555 and a pin code of 12345. The org_id and tokens will be populated from the cached created by Connect-Verkada. - - .EXAMPLE - Add-VerkadaAccessUser -firstName 'New' -lastName 'User' -email 'newUser@contoso.com' -cardType 'HID' -facilityCode 111 -cardNumber 55555 -groupId 'df76sd-dsc-group1','dsf987-daf-group2' - This will add the access user with the name "New User" and email newUser@contoso.com with an HID badge 111-55555 and in groups df76sd-dsc-group1 and dsf987-daf-group2. The org_id and tokens will be populated from the cached created by Connect-Verkada. - #> - - [CmdletBinding(PositionalBinding = $true)] - Param( - #The UUID of the organization the user belongs to - [Parameter(ValueFromPipelineByPropertyName = $true)] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [String]$org_id = $Global:verkadaConnection.org_id, - #The email address of the user being added - [Parameter(ValueFromPipelineByPropertyName = $true)] - [String]$email, - #The first name of the user being added - [Parameter(ValueFromPipelineByPropertyName = $true)] - [String]$firstName, - #The last name of the user being added - [Parameter(ValueFromPipelineByPropertyName = $true)] - [String]$lastName, - #The Verkada(CSRF) token of the user running the command - [Parameter()] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [string]$x_verkada_token = $Global:verkadaConnection.csrfToken, - #The Verkada Auth(session auth) token of the user running the command - [Parameter()] - [ValidateNotNullOrEmpty()] - [string]$x_verkada_auth = $Global:verkadaConnection.userToken, - #The phone number of the user being added - [Parameter(ValueFromPipelineByPropertyName = $true)] - [ValidatePattern("^\+\d{11}")] - [String]$phone, - #The role of the user being added. - [Parameter(ValueFromPipelineByPropertyName = $true)] - [ValidateSet('ORG_MEMBER','ADMIN')] - [String]$role='ORG_MEMBER', - #Start date/time of the user being added - [Parameter(ValueFromPipelineByPropertyName = $true)] - [datetime]$start, - #End date/time of the user being added - [Parameter(ValueFromPipelineByPropertyName = $true)] - [datetime]$expiration, - #Boolean on whether to send invite email to newly created user - [Parameter(ValueFromPipelineByPropertyName = $true)] - [bool]$sendInviteEmail=$false, - #The card type of the card being added - [Parameter(ValueFromPipelineByPropertyName = $true)] - [String]$cardType, - #The card number of the card being added (Mutually exclusive with CardHex) - [Parameter(ValueFromPipelineByPropertyName = $true)] - [String]$cardNumber, - #The card Number Hex of the card being added (Mutually exclusive with Card Number) - [Parameter(ValueFromPipelineByPropertyName = $true)] - [String]$cardNumberHex, - #The facility code of the card being added - [Parameter(ValueFromPipelineByPropertyName = $true)] - [String]$facilityCode, - #The pin code being added - [Parameter(ValueFromPipelineByPropertyName = $true)] - [ValidatePattern('^\d{4,16}$')] - [Alias('pin')] - [String]$pinCode, - #The UUID of the group or groups the user should be added to on creation - [Parameter(ValueFromPipelineByPropertyName = $true)] - [String[]]$groupId, - #The name of the group or groups the user should be added to on creation(not currently implemented) - [Parameter(ValueFromPipelineByPropertyName = $true)] - [String[]]$groupName, - #The employee ID of the user - [Parameter(ValueFromPipelineByPropertyName = $true)] - [String]$employeeId, - #The title of the user - [Parameter(ValueFromPipelineByPropertyName = $true)] - [String]$employeeTitle, - #The department of the user - [Parameter(ValueFromPipelineByPropertyName = $true)] - [String]$department, - #The departmentId of the user - [Parameter(ValueFromPipelineByPropertyName = $true)] - [String]$departmentId, - #The company name of the user - [Parameter(ValueFromPipelineByPropertyName = $true)] - [String]$companyName, - #The UUID of the user account making the request - [Parameter()] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [string]$usr = $Global:verkadaConnection.usr, - #Number of threads allowed to multi-thread the task - [Parameter()] - [ValidateRange(1,20)] - [int]$threads=4 - ) - - Begin { - #parameter validation - if ([string]::IsNullOrEmpty($org_id)) {throw "org_id is missing but is required!"} - if ([string]::IsNullOrEmpty($x_verkada_token)) {throw "x_verkada_token is missing but is required!"} - if ([string]::IsNullOrEmpty($x_verkada_auth)) {throw "x_verkada_auth is missing but is required!"} - - $url = "https://vcerberus.command.verkada.com/users/create" - - $jobs = @() - $vMod = Get-Module verkadaModule | Select-Object -ExpandProperty Path - } #end begin - - Process { - #decide which parameter set is presented for first/last name and email - if ([string]::IsNullOrEmpty($firstName) -and [string]::IsNullOrEmpty($lastName) -and [string]::IsNullOrEmpty($email)){ - Write-Warning "No user created since no email or name was presented. An email and/or First/Last Name are required to create a user." - return - } elseif ((!([string]::IsNullOrEmpty($firstName))) -and (!([string]::IsNullOrEmpty($lastName))) -and (!([string]::IsNullOrEmpty($email)))) { - #write-host "$firstName $lastName $email are all present" -ForegroundColor Red - } elseif ((!([string]::IsNullOrEmpty($email))) -and [string]::IsNullOrEmpty($firstName) -and [string]::IsNullOrEmpty($lastName)) { - #write-host "$email is the only thing present" -ForegroundColor Red - } elseif (([string]::IsNullOrEmpty($firstName) -or [string]::IsNullOrEmpty($lastName))) { - Write-Warning "No user created since either the first or last name is missing. First and Last Name are required to create a user if one is specified." - return - } elseif ((!([string]::IsNullOrEmpty($firstName)) -and (!([string]::IsNullOrEmpty($lastName)))) -and [string]::IsNullOrEmpty($email)) { - #write-host "$firstName $lastname were specified and no email" -ForegroundColor Red - } - - #build the form parameters for the user creation - $form_params = @{ - "organizationId" = $org_id - } - if (!([string]::IsNullOrEmpty($email))){$form_params.email = $email} - if (!([string]::IsNullOrEmpty($firstName))){$form_params.firstName = $firstName} - if (!([string]::IsNullOrEmpty($lastName))){$form_params.lastName = $lastName} - if (!([string]::IsNullOrEmpty($phone))){$form_params.phone = $phone} - if (!([string]::IsNullOrEmpty($role))){$form_params.role = $role} - if (!([string]::IsNullOrEmpty($start))){$form_params.start = ([DateTimeOffset]($start)).ToUnixTimeSeconds()} - if (!([string]::IsNullOrEmpty($expiration))){$form_params.expiration = ([DateTimeOffset]($expiration)).ToUnixTimeSeconds()} - if (!([string]::IsNullOrEmpty($sendInviteEmail))){$form_params.sendInviteEmail = $sendInviteEmail.ToString().ToLower()} - - #start a threadJob for each user addition - $jobs += Start-ThreadJob -ThrottleLimit $threads -ScriptBlock { - Import-Module $using:vMod - #Add the user to Command - #Write-Output "Add user $using:firstName $using:lastName $using:email" - $res = @{} - try { - $output = Invoke-VerkadaFormCall $using:url $using:org_id $using:form_params -x_verkada_token $using:x_verkada_token -x_verkada_auth $using:x_verkada_auth - $res.created = ((Get-Date -Date "01-01-1970") + ([System.TimeSpan]::FromSeconds(($output.users.created)))).ToLocalTime() - $res.userId = $output.users.userId - $res.firstName = $output.users.firstName - $res.lastName = $output.users.lastName - $res.email = $output.users.email - - $response = $res | ConvertTo-Json -Depth 100 | ConvertFrom-Json - } - catch [Microsoft.PowerShell.Commands.HttpResponseException] { - $err = $_.ErrorDetails | ConvertFrom-Json - $errorMes = $_ | Convertto-Json -WarningAction SilentlyContinue - $err | Add-Member -NotePropertyName StatusCode -NotePropertyValue (($errorMes | ConvertFrom-Json -Depth 100 -WarningAction SilentlyContinue).Exception.Response.StatusCode) -Force - - $res.created = '0' - $res.firstName = $using:firstName - $res.lastName = $using:lastName - $res.email = $using:email - - Write-Warning "$using:firstName $using:lastName $using:email was not created due to: $($err.StatusCode) - $($err.message)" - $noUser = $true - } - catch { - $_.Exception - $noUser = $true - } - finally { - $response = $res | ConvertTo-Json -Depth 100 | ConvertFrom-Json - } - if ($noUser){return} - - #Add badge to user if present - if (!([string]::IsNullOrEmpty($using:cardType))){ - #Write-Output "Add badge $using:cardType $using:cardNumber $using:cardNumberHex $using:facilityCode" - #Write-Output "Need to verify cardnumber or cardnumberhex are present as well as other card error handling" - if (([string]::IsNullOrEmpty($using:cardNumber)) -and ([string]::IsNullOrEmpty($using:cardNumberHex))){ - #check to see if both cardnumber and cardnumberhex are exmpty - Write-Warning "No card is being added to $using:firstName $using:lastName $using:email as both cardnumber and cardnumberhex are missing. One is required." - $res.accessCards = '' - } elseif ((!([string]::IsNullOrEmpty($using:cardNumber))) -and (!([string]::IsNullOrEmpty($using:cardNumberHex)))) { - #check to see if both cardnumber and cardnumberhex are present - Write-Warning "No card is being added to $using:firstName $using:lastName $using:email as a cardnumber and cardnumberhex were submitted. They are mutually exclusive." - $res.accessCards = '' - } else { - $eval = "`$response | Add-VerkadaAccessBadgeToUser -org_id $using:org_id -x_verkada_token $using:x_verkada_token -x_verkada_auth $using:x_verkada_auth -cardType $using:cardType" - if (!([string]::IsNullOrEmpty($using:cardNumber))){$eval +=" -cardNumber $using:cardNumber"} - if (!([string]::IsNullOrEmpty($using:cardNumberHex))){$eval +=" -cardNumberHex $using:cardNumberHex"} - if (!([string]::IsNullOrEmpty($using:facilityCode))){$eval +=" -facilityCode $using:facilityCode"} - - try { - $output2 = invoke-expression $eval - $res.accessCards = $output2.accessCards - } - catch { - if ($_.Exception.Message -match '^\d{3}\s-\s.*') { - Write-Warning "No card is being added to $using:firstName $using:lastName $using:email due to: $($_.Exception.Message)" - } else { - $_.Exception - } - $res.accessCards = '' - } - } - } else {$res.accessCards = ''} - - #Add pin to user if present - if (!([string]::IsNullOrEmpty($using:pinCode))){ - try { - $outputPin = $response | Add-VerkadaAccessUserPin -pinCode $using:pinCode -org_id $using:org_id -x_verkada_token $using:x_verkada_token -x_verkada_auth $using:x_verkada_auth - $res.pinCode = $outputPin.code - } - catch { - if ($_.Exception.Message -match '^\d{3}\s-\s.*') { - Write-Warning "No pin is being added to $using:firstName $using:lastName $using:email due to: $($_.Exception.Message)" - } else { - $_.Exception - } - $res.pinCode = '' - } - } else {$res.pinCode = ''} - - #add user to group/s if present - if (!([string]::IsNullOrEmpty($using:groupId))){ - #validate group is proper UUID - $res.groupIds = @() - switch -Regex ($using:groupId) { - '^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$' { - #Write-Output "Adding $using:firstName $using:lastName to $_" - try { - $response | Add-VerkadaAccessUserToGroup -groupId $_ -org_id $using:org_id -x_verkada_token $using:x_verkada_token -x_verkada_auth $using:x_verkada_auth | Out-Null - $res.groupIds += $_ - } - catch { - Write-Warning "$using:firstName $using:lastName $using:email was not added to the groupID provided ($_) due to: $($_.Exception.Message)" - } - } - default {Write-Warning "$using:firstName $using:lastName $using:email was not added to the groupID provided ($_) as it is not a valid UUID"} - } - - } elseif (!([string]::IsNullOrEmpty($using:groupName))) { - <# Action when this condition is true #> - } - - #add employment deatils if present - $employment = @{} - $eval3 = "Set-VerkadaAccessUserEmployementDetail -org_id $using:org_id -usr $using:usr -x_verkada_token $using:x_verkada_token -x_verkada_auth $using:x_verkada_auth -userId $($response.userId)" - if (!([string]::IsNullOrEmpty($using:employeeId))){$employment.employeeId = $using:employeeId; $eval3 +=" -employeeId `$using:employeeId"} - if (!([string]::IsNullOrEmpty($using:employeeTitle))){$employment.employeeTitle = $using:employeeTitle; $eval3 +=" -employeeTitle `$using:employeeTitle"} - if (!([string]::IsNullOrEmpty($using:department))){$employment.department = $using:department; $eval3 +=" -department `$using:department"} - if (!([string]::IsNullOrEmpty($using:departmentId))){$employment.departmentId = $using:departmentId; $eval3 +=" -departmentId `$using:departmentId"} - if (!([string]::IsNullOrEmpty($using:companyName))){$employment.companyName = $using:companyName; $eval3 +=" -companyName `$using:companyName"} - - #check tp see if any employment details are present - if ($employment.Count){ - try { - $employment.userId = $response.userId - $output3 = invoke-expression $eval3 - $res.employeeId = $output3.employeeId - $res.employeeTitle = $output3.employeeTitle - $res.department = $output3.department - $res.departmentId = $output3.departmentId - $res.companyName = $output3.companyName - } - catch { - if ($_.Exception.Message -match '^\d{3}\s-\s.*') { - Write-Warning "No employment details were updated for $using:firstName $using:lastName $using:email due to: $($_.Exception.Message)" - } else { - $_.Exception - } - $res.employeeId = '' - $res.employeeTitle = '' - $res.department = '' - $res.departmentId = '' - $res.companyName = '' - } - } else { - $res.employeeId = '' - $res.employeeTitle = '' - $res.department = '' - $res.departmentId = '' - $res.companyName = '' - } - #aggregated response output - $response = $res | ConvertTo-Json -Depth 100 | ConvertFrom-Json - $response - } - } #end process - - End { - $jobs | Receive-Job -AutoRemoveJob -Wait -WarningVariable +w -ErrorVariable +e - foreach ($line in $w){Write-Output "Warning: $line"} - foreach ($line in $e){Write-Output "Error: $line"} - Remove-Variable -Name w -ErrorAction SilentlyContinue - Remove-Variable -Name e -ErrorAction SilentlyContinue - } #end end -} #end function \ No newline at end of file diff --git a/verkadaModule/Public/Add-VerkadaAccessUserPin.ps1 b/verkadaModule/Public/Add-VerkadaAccessUserPin.ps1 deleted file mode 100644 index 1c1ccbd..0000000 --- a/verkadaModule/Public/Add-VerkadaAccessUserPin.ps1 +++ /dev/null @@ -1,90 +0,0 @@ -function Add-VerkadaAccessUserPin { - <# - .SYNOPSIS - Adds a Pin code to an Access User in an organization - - .DESCRIPTION - This function is used to add a Pin code to a Verkada access user. - The org_id and reqired tokens can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands. - - .LINK - https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessUserPin.md - - .EXAMPLE - Add-VerkadaAccessUserPin -userId 'gjg547-uuid-of-user' -pinCode '12345' - This will add a pin code of 12345 to the user specified. The org_id and tokens will be populated from the cached created by Connect-Verkada. - - .EXAMPLE - Add-VerkadaAccessUserPin -userId 'gjg547-uuid-of-user' -pinCode '12345' -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_token 'a366ef47-2c20-4d35-a90a-10fd2aee113a' -x_verkada_auth 'auth-token-uuid-dscsdc' - This will add a pin code of 12345 to the user specified. The org_id and tokens are submitted as parameters in the call. - - .EXAMPLE - Import-Csv ./myUserPins.csv | Add-VerkadaAccessUserPin - This will add a Pin code for every row in the csv file which contains userId, and pinCode. The org_id and tokens will be populated from the cached created by Connect-Verkada. - #> - - [CmdletBinding(PositionalBinding = $true)] - param ( - #The UUID of the organization the user belongs to - [Parameter(ValueFromPipelineByPropertyName = $true)] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [String]$org_id = $Global:verkadaConnection.org_id, - #The UUID of the user the pin code is being added to - [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [String]$userId, - #The pin code being added - [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 1)] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^\d{4,16}$')] - [Alias('pin')] - [String]$pinCode, - #The Verkada(CSRF) token of the user running the command - [Parameter()] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [string]$x_verkada_token = $Global:verkadaConnection.csrfToken, - #The Verkada Auth(session auth) token of the user running the command - [Parameter()] - [ValidateNotNullOrEmpty()] - [string]$x_verkada_auth = $Global:verkadaConnection.userToken, - #Number of threads allowed to multi-thread the task - [Parameter()] - [ValidateRange(1,4)] - [int]$threads=$null - ) - - begin { - #parameter validation - if ([string]::IsNullOrEmpty($org_id)) {throw "org_id is missing but is required!"} - if ([string]::IsNullOrEmpty($x_verkada_token)) {throw "x_verkada_token is missing but is required!"} - if ([string]::IsNullOrEmpty($x_verkada_auth)) {throw "x_verkada_auth is missing but is required!"} - - $url = "https://vcerberus.command.verkada.com/user/code/set" - } #end begin - - process { - $body_params = @{ - "userId" = $userId - "organizationId" = $org_id - "code" = $pinCode - } - - try { - Invoke-VerkadaRestMethod $url $org_id $body_params -x_verkada_token $x_verkada_token -x_verkada_auth $x_verkada_auth -Method 'POST' -UnPwd | Select-Object -ExpandProperty userCodes - } - catch [Microsoft.PowerShell.Commands.HttpResponseException] { - $err = $_.ErrorDetails | ConvertFrom-Json - $errorMes = $_ | Convertto-Json -WarningAction SilentlyContinue - $err | Add-Member -NotePropertyName StatusCode -NotePropertyValue (($errorMes | ConvertFrom-Json -Depth 100 -WarningAction SilentlyContinue).Exception.Response.StatusCode) -Force - - throw "$($err.StatusCode) - $($err.message)" - } - } #end process - - end { - - } #end end -} #end function \ No newline at end of file diff --git a/verkadaModule/Public/Add-VerkadaAccessUserToGroup.ps1 b/verkadaModule/Public/Add-VerkadaAccessUserToGroup.ps1 deleted file mode 100644 index 44ccc96..0000000 --- a/verkadaModule/Public/Add-VerkadaAccessUserToGroup.ps1 +++ /dev/null @@ -1,88 +0,0 @@ -function Add-VerkadaAccessUserToGroup -{ - <# - .SYNOPSIS - Adds an Access User to an Access Group in an organization - - .DESCRIPTION - This function is used to add a Verkada Access user to a group or groups. - The org_id and reqired tokens can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands. - - .LINK - https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessUserToGroup.md - - .EXAMPLE - Add-VerkadaAccessUserToGroup -userid 'dcscsdc-dsc-user1' -groupId 'df76sd-dsc-group1','dsf987-daf-group2' - This will add the userid dcscsdc-dsc-user1 to access groups df76sd-dsc-group1 and dsf987-daf-group2. The org_id and tokens will be populated from the cached created by Connect-Verkada. - - .EXAMPLE - Add-VerkadaAccessUserToGroup -userid 'dcscsdc-dsc-user1' -groupId 'df76sd-dsc-group1','dsf987-daf-group2' -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_token 'a366ef47-2c20-4d35-a90a-10fd2aee113a' -x_verkada_auth 'auth-token-uuid-dscsdc' - This will add the userid dcscsdc-dsc-user1 to access groups df76sd-dsc-group1 and dsf987-daf-group2. The org_id and tokens are submitted as parameters in the call. - #> - - [CmdletBinding(PositionalBinding = $true, DefaultParameterSetName = 'email')] - Param( - #The UUID of the organization the user belongs to - [Parameter(ValueFromPipelineByPropertyName = $true)] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [String]$org_id = $Global:verkadaConnection.org_id, - #The UUID of the user the badge is being added to - [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [String[]]$userId, - #The UUID of the group or groups the user should be added to - [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'groupId')] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [String[]]$groupId, - #The name of the group or groups the user should be added to on creation(not currently implemented) - [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'groupName')] - [String[]]$groupName, - #The Verkada(CSRF) token of the user running the command - [Parameter()] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [string]$x_verkada_token = $Global:verkadaConnection.csrfToken, - #The Verkada Auth(session auth) token of the user running the command - [Parameter()] - [ValidateNotNullOrEmpty()] - [string]$x_verkada_auth = $Global:verkadaConnection.userToken, - #Number of threads allowed to multi-thread the task - [Parameter()] - [ValidateRange(1,4)] - [int]$threads=$null - ) - - Begin { - #parameter validation - if ([string]::IsNullOrEmpty($org_id)) {throw "org_id is missing but is required!"} - if ([string]::IsNullOrEmpty($x_verkada_token)) {throw "x_verkada_token is missing but is required!"} - if ([string]::IsNullOrEmpty($x_verkada_auth)) {throw "x_verkada_auth is missing but is required!"} - - $url = "https://vcerberus.command.verkada.com/user_groups/bulk_add_users" - } #end begin - - Process { - $body_params = @{ - "userIds" = $userId - "organizationId" = $org_id - "groupIds" = $groupId - } - - try { - Invoke-VerkadaRestMethod $url $org_id $body_params -x_verkada_token $x_verkada_token -x_verkada_auth $x_verkada_auth -Method 'POST' -UnPwd - } - catch [Microsoft.PowerShell.Commands.HttpResponseException] { - $err = $_.ErrorDetails | ConvertFrom-Json - $errorMes = $_ | Convertto-Json -WarningAction SilentlyContinue - $err | Add-Member -NotePropertyName StatusCode -NotePropertyValue (($errorMes | ConvertFrom-Json -Depth 100 -WarningAction SilentlyContinue).Exception.Response.StatusCode) -Force - - throw "$($err.StatusCode) - $($err.message)" - } - } #end process - - End { - - } #end end -} #end function \ No newline at end of file diff --git a/verkadaModule/Public/Export-VerkadaAccessUserProfilePicture.ps1 b/verkadaModule/Public/Export-VerkadaAccessUserProfilePicture.ps1 deleted file mode 100644 index 7061771..0000000 --- a/verkadaModule/Public/Export-VerkadaAccessUserProfilePicture.ps1 +++ /dev/null @@ -1,120 +0,0 @@ -function Export-VerkadaAccessUserProfilePicture{ - <# - .SYNOPSIS - Downloads a copy of the current Verkada Access profile picture. - - .DESCRIPTION - This will download the Access user's, specified by the userId, current profile picture. - The org_id and reqired tokens can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands. - - .LINK - https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Export-VerkadaAccessUserProfilePicture.md - - .EXAMPLE - Export-VerkadaAccessUserProfilePicture -userId '801c9551-b04c-4293-84ad-b0a6aa0588b3' -outPath './MyProfilePics' - This downloads the Access user's, with userId 801c9551-b04c-4293-84ad-b0a6aa0588b3, picture to ./MyProfilePics/801c9551-b04c-4293-84ad-b0a6aa0588b3.jpg. The org_id and tokens will be populated from the cached created by Connect-Verkada. - - .EXAMPLE - Find-VerkadaUserId -email 'some.user@contoso.com' | Export-VerkadaAccessUserProfilePicture - This downloads the Access user's, with email some.user@contoso.com, picture to ./MyProfilePics/801c9551-b04c-4293-84ad-b0a6aa0588b3.jpg. The org_id and tokens will be populated from the cached created by Connect-Verkada. - - .EXAMPLE - Export-VerkadaAccessUserProfilePicture -userId '801c9551-b04c-4293-84ad-b0a6aa0588b3' -outPath './MyProfilePics' -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_token 'a366ef47-2c20-4d35-a90a-10fd2aee113a' -x_verkada_auth 'auth-token-uuid-dscsdc' -usr 'a099bfe6-34ff-4976-9d53-ac68342d2b60' - This downloads the Access user's, with userId 801c9551-b04c-4293-84ad-b0a6aa0588b3, picture to ./MyProfilePics/801c9551-b04c-4293-84ad-b0a6aa0588b3.jpg. The org_id and tokens are submitted as parameters in the call. - #> - [CmdletBinding(PositionalBinding = $true)] - [Alias("Export-VrkdaAcUsrPrflPic","ep-VrkdaAcUsrPrflPic")] - param ( - #The UUID of the user - [Parameter(ValueFromPipelineByPropertyName = $true)] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [Alias('user_id')] - [String]$userId, - #This is the path the picture/s will attempt to be saved to - [Parameter()] - [string]$outPath='./', - #The UUID of the organization the user belongs to - [Parameter(ValueFromPipelineByPropertyName = $true)] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [String]$org_id = $Global:verkadaConnection.org_id, - #The Verkada(CSRF) token of the user running the command - [Parameter()] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [string]$x_verkada_token = $Global:verkadaConnection.csrfToken, - #The Verkada Auth(session auth) token of the user running the command - [Parameter()] - [ValidateNotNullOrEmpty()] - [string]$x_verkada_auth = $Global:verkadaConnection.userToken, - #The UUID of the user account making the request - [Parameter()] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [string]$usr = $Global:verkadaConnection.usr - ) - - begin { - #parameter validation - if ([string]::IsNullOrEmpty($org_id)) {throw "org_id is missing but is required!"} - if ([string]::IsNullOrEmpty($x_verkada_token)) {throw "x_verkada_token is missing but is required!"} - if ([string]::IsNullOrEmpty($x_verkada_auth)) {throw "x_verkada_auth is missing but is required!"} - if ([string]::IsNullOrEmpty($usr)) {throw "usr is missing but is required!"} - - $Body = '' - } #end begin - - process { - if ([string]::IsNullOrEmpty($userId)){ - Write-Error "userId required" - return - } - - $url = "https://vcerberus.command.verkada.com/user/photos/$org_id/$userId/512.jpg" - - function testOutPath { - param ($folderPath) - try { - if([string]::IsNullOrEmpty($folderPath)){Throw "no path provided"} - Get-ChildItem -Path $folderPath -ErrorAction Stop | Out-Null - $folderPath = ($folderPath | Resolve-Path).Path - return $folderPath - } - catch { - Write-Warning $_.Exception.Message - $folderPath = Read-Host -Prompt 'Please provide a valid folder path for the AC profile picture/s to be saved to.' - testOutPath $folderPath - } - } - - $outPath = testOutPath $outPath - $outFile = Join-Path $outPath "$userId.jpg" - - try { - $testPic = Test-VerkadaAccessProfilePictureUrl -userId $userId -org_id $org_id -x_verkada_token $x_verkada_token -x_verkada_auth $x_verkada_auth -usr $usr - - if ($testPic.profilePicture -eq $true){ - Invoke-VerkadaCommandCall $URL $org_id $Body -x_verkada_token $x_verkada_token -x_verkada_auth $x_verkada_auth -usr $usr -Method 'GET' -outFile $outFile - Write-Host "Profile picture exported to $outFile" -ForegroundColor Green - } - else { - Write-Host "No profile picture exists for $userId" -ForegroundColor Red - } - - } - catch [Microsoft.PowerShell.Commands.HttpResponseException] { - $err = $_.ErrorDetails | ConvertFrom-Json - $errorMes = $_ | Convertto-Json -WarningAction SilentlyContinue - $err | Add-Member -NotePropertyName StatusCode -NotePropertyValue (($errorMes | ConvertFrom-Json -Depth 100 -WarningAction SilentlyContinue).Exception.Response.StatusCode) -Force - - Write-Host "$($err.StatusCode) - $($err.message)" -ForegroundColor Red - Return - } - - } #end process - - end { - - } #end end -} #end function \ No newline at end of file diff --git a/verkadaModule/Public/Get-VerkadaAccessUserProfilePicture.ps1 b/verkadaModule/Public/Get-VerkadaAccessUserProfilePicture.ps1 new file mode 100644 index 0000000..200b3be --- /dev/null +++ b/verkadaModule/Public/Get-VerkadaAccessUserProfilePicture.ps1 @@ -0,0 +1,141 @@ +function Get-VerkadaAccessUserProfilePicture{ + <# + .SYNOPSIS + Retrieves a profile photo for the specified Access user using https://apidocs.verkada.com/reference/getprofilephotoviewv1 + + .DESCRIPTION + This will download the Access user's, specified by the user_Id or external_Id, current profile picture. + The org_id and reqired token can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands. + + .LINK + https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Get-VerkadaAccessUserProfilePicture.md + + .EXAMPLE + Export-VerkadaAccessUserProfilePicture -userId '801c9551-b04c-4293-84ad-b0a6aa0588b3' -outPath './MyProfilePics' + This downloads the Access user's, with userId 801c9551-b04c-4293-84ad-b0a6aa0588b3, picture to ./MyProfilePics/801c9551-b04c-4293-84ad-b0a6aa0588b3.jpg. The org_id and token will be populated from the cached created by Connect-Verkada. + + .EXAMPLE + Export-VerkadaAccessUserProfilePicture -externalId 'newUserUPN@contoso.com' -outPath './MyProfilePics' -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_auth_api 'sd78ds-uuid-of-verkada-token' + This downloads the Access user's, with externalId newUserUPN@contoso.com picture to ./MyProfilePics/newUserUPN.jpg. The org_id and token are submitted as parameters in the call. + #> + [CmdletBinding(PositionalBinding = $true)] + [Alias("Export-VerkadaAccessUserProfilePicture","Get-VrkdaAcUsrPrflPic","g-VrkdaAcUsrPrflPic","Export-VrkdaAcUsrPrflPic","ep-VrkdaAcUsrPrflPic")] + param ( + #The UUID of the user + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateNotNullOrEmpty()] + [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] + [Alias('user_id')] + [String]$userId, + #unique identifier managed externally provided by the consumer + [Parameter(ValueFromPipelineByPropertyName = $true)] + [Alias('external_id')] + [String]$externalId, + #This is the path the picture/s will attempt to be saved to + [Parameter()] + [string]$outPath='./', + #The flag that states whether to download the original or cropped version + [Parameter(ValueFromPipelineByPropertyName = $true)] + [bool]$original=$false, + #The UUID of the organization the user belongs to + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateNotNullOrEmpty()] + [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] + [String]$org_id = $Global:verkadaConnection.org_id, + #The public API token obatined via the Login endpoint to be used for calls that hit the public API gateway + [Parameter()] + [ValidateNotNullOrEmpty()] + [String]$x_verkada_auth_api = $Global:verkadaConnection.x_verkada_auth_api, + #The region of the public API to be used + [Parameter()] + [ValidateSet('api','api.eu','api.au')] + [String]$region='api', + #Switch to write errors to file + [Parameter()] + [switch]$errorsToFile + ) + + begin { + $url = "https://$($region).verkada.com/access/v1/access_users/user/profile_photo" + #parameter validation + if ([string]::IsNullOrEmpty($org_id)) {throw "org_id is missing but is required!"} + if ([string]::IsNullOrEmpty($x_verkada_auth_api)) {throw "x_verkada_auth_api is missing but is required!"} + $myErrors = @() + } #end begin + + process { + if ([string]::IsNullOrEmpty($externalId) -and [string]::IsNullOrEmpty($userId)){ + Write-Error "Either externalId or userId required" + return + } + + if (!([string]::IsNullOrEmpty($userId))){ + $hasPhoto = Get-VerkadaAccessUser -userId $userId -org_id $org_id -x_verkada_auth_api $x_verkada_auth_api -region $region | Select-Object -ExpandProperty has_profile_photo + if (!($hasPhoto)){throw "No profile picture exists for $userId"} + } elseif (!([string]::IsNullOrEmpty($externalId))){ + $hasPhoto = Get-VerkadaAccessUser -externalId $externalId -org_id $org_id -x_verkada_auth_api $x_verkada_auth_api -region $region | Select-Object -ExpandProperty has_profile_photo + if (!($hasPhoto)){throw "No profile picture exists for $externalId"} + } + + $body_params = @{} + function testOutPath { + param ($folderPath) + try { + if([string]::IsNullOrEmpty($folderPath)){Throw "no path provided"} + Get-ChildItem -Path $folderPath -ErrorAction Stop | Out-Null + $folderPath = ($folderPath | Resolve-Path).Path + return $folderPath + } + catch { + Write-Warning $_.Exception.Message + $folderPath = Read-Host -Prompt 'Please provide a valid folder path for the AC profile picture/s to be saved to.' + testOutPath $folderPath + } + } + + $outPath = testOutPath $outPath + + $query_params = @{ + 'original' = $original + } + + if (!([string]::IsNullOrEmpty($userId))){ + $query_params.user_id = $userId + $outFile = Join-Path $outPath "$userId.jpg" + } elseif (!([string]::IsNullOrEmpty($externalId))){ + $query_params.external_id = $externalId + $outFile = Join-Path $outPath "$($externalId.TrimEnd().Split('@')[0].replace('.','_')).jpg" + } + + try { + Invoke-VerkadaRestMethod $url $org_id $x_verkada_auth_api $query_params -method GET -outFile $outFile + return + } + catch [Microsoft.PowerShell.Commands.HttpResponseException] { + $err = $_.ErrorDetails | ConvertFrom-Json + $errorMes = $_ | Convertto-Json -WarningAction SilentlyContinue + $err | Add-Member -NotePropertyName StatusCode -NotePropertyValue (($errorMes | ConvertFrom-Json -Depth 100 -WarningAction SilentlyContinue).Exception.Response.StatusCode) -Force + $msg = "$($err.StatusCode) - $($err.message)" + $msg += ": $(($query_params + $body_params) | ConvertTo-Json -Compress)" + Write-Error $msg + $myErrors += $msg + $msg = $null + } + catch [VerkadaRestMethodException] { + $msg = $_.ToString() + $msg += ": $(($query_params + $body_params) | ConvertTo-Json -Compress)" + Write-Error $msg + $myErrors += $msg + $msg = $null + } + } #end process + + end { + if ($errorsToFile.IsPresent){ + if (![string]::IsNullOrEmpty($myErrors)){ + Get-Date | Out-File ./errors.txt -Append + $myErrors | Out-File ./errors.txt -Append + } + } + } #end end +} #end function \ No newline at end of file diff --git a/verkadaModule/Public/Remove-VerkadaAccessUserProfilePicture.ps1 b/verkadaModule/Public/Remove-VerkadaAccessUserProfilePicture.ps1 index ecdc35c..0a9bc97 100644 --- a/verkadaModule/Public/Remove-VerkadaAccessUserProfilePicture.ps1 +++ b/verkadaModule/Public/Remove-VerkadaAccessUserProfilePicture.ps1 @@ -1,11 +1,11 @@ function Remove-VerkadaAccessUserProfilePicture{ <# .SYNOPSIS - Removes an Access user's profile picture in an organization. + Deletes a profile photo for the specified user using https://apidocs.verkada.com/reference/deleteprofilephotoviewv1 .DESCRIPTION - This will remove the Access user's, specified by the userId, profile picture. - The org_id and reqired tokens can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands. + This will remove the Access user's, specified by the user_Id or external_Id, profile picture. + The org_id and reqired token can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands. .LINK https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Remove-VerkadaAccessUserProfilePicture.md @@ -15,8 +15,8 @@ function Remove-VerkadaAccessUserProfilePicture{ This removes the Access user's profile picture with userId 801c9551-b04c-4293-84ad-b0a6aa0588b3. The org_id and tokens will be populated from the cached created by Connect-Verkada. .EXAMPLE - Remove-VerkadaAccessUserProfilePicture -userId '801c9551-b04c-4293-84ad-b0a6aa0588b3' -x_verkada_token 'a366ef47-2c20-4d35-a90a-10fd2aee113a' -x_verkada_auth 'auth-token-uuid-dscsdc' -usr 'a099bfe6-34ff-4976-9d53-ac68342d2b60' - This removes the Access user's profile picture with userId 801c9551-b04c-4293-84ad-b0a6aa0588b3. The org_id and tokens are submitted as parameters in the call. + Remove-VerkadaAccessUserProfilePicture -externalId 'newUserUPN@contoso.com' -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_auth_api 'sd78ds-uuid-of-verkada-token' + This removes the Access user's profile picture with externalId newUserUPN@contoso.com. The org_id and tokens are submitted as parameters in the call. #> [CmdletBinding(PositionalBinding = $true)] [Alias("Remove-VrkdaAcUsrPrflPic","rm-VrkdaAcUsrPrflPic")] @@ -27,65 +27,79 @@ function Remove-VerkadaAccessUserProfilePicture{ [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] [Alias('user_id')] [String]$userId, + #unique identifier managed externally provided by the consumer + [Parameter(ValueFromPipelineByPropertyName = $true)] + [Alias('external_id')] + [String]$externalId, #The UUID of the organization the user belongs to [Parameter(ValueFromPipelineByPropertyName = $true)] [ValidateNotNullOrEmpty()] [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] [String]$org_id = $Global:verkadaConnection.org_id, - #The Verkada(CSRF) token of the user running the command + #The public API token obatined via the Login endpoint to be used for calls that hit the public API gateway [Parameter()] [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [string]$x_verkada_token = $Global:verkadaConnection.csrfToken, - #The Verkada Auth(session auth) token of the user running the command + [String]$x_verkada_auth_api = $Global:verkadaConnection.x_verkada_auth_api, + #The region of the public API to be used [Parameter()] - [ValidateNotNullOrEmpty()] - [string]$x_verkada_auth = $Global:verkadaConnection.userToken, - #The UUID of the user account making the request + [ValidateSet('api','api.eu','api.au')] + [String]$region='api', + #Switch to write errors to file [Parameter()] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [string]$usr = $Global:verkadaConnection.usr + [switch]$errorsToFile ) begin { + $url = "https://$($region).verkada.com/access/v1/access_users/user/profile_photo" #parameter validation if ([string]::IsNullOrEmpty($org_id)) {throw "org_id is missing but is required!"} - if ([string]::IsNullOrEmpty($x_verkada_token)) {throw "x_verkada_token is missing but is required!"} - if ([string]::IsNullOrEmpty($x_verkada_auth)) {throw "x_verkada_auth is missing but is required!"} - if ([string]::IsNullOrEmpty($usr)) {throw "usr is missing but is required!"} - - $body = @{} + if ([string]::IsNullOrEmpty($x_verkada_auth_api)) {throw "x_verkada_auth_api is missing but is required!"} + $myErrors = @() } #end begin process { - if ([string]::IsNullOrEmpty($userId)){ - Write-Error "userId required" + if ([string]::IsNullOrEmpty($externalId) -and [string]::IsNullOrEmpty($userId)){ + Write-Error "Either externalId or userId required" return } - - $url = "https://vcerberus.command.verkada.com/user/photos/$org_id/$userId" - + $body_params = @{} + + $query_params = @{} + if (!([string]::IsNullOrEmpty($userId))){ + $query_params.user_id = $userId + } elseif (!([string]::IsNullOrEmpty($externalId))){ + $query_params.external_id = $externalId + } + try { - Invoke-VerkadaCommandCall $url $org_id $body -x_verkada_token $x_verkada_token -x_verkada_auth $x_verkada_auth -usr $usr -Method 'DELETE' - return "Profile pictured removed from user $userId" + Invoke-VerkadaRestMethod $url $org_id $x_verkada_auth_api $query_params -body_params $body_params -method 'DELETE' + return "Profile pictured removed from user $($query_params | ConvertTo-Json -Compress)" } catch [Microsoft.PowerShell.Commands.HttpResponseException] { $err = $_.ErrorDetails | ConvertFrom-Json $errorMes = $_ | Convertto-Json -WarningAction SilentlyContinue $err | Add-Member -NotePropertyName StatusCode -NotePropertyValue (($errorMes | ConvertFrom-Json -Depth 100 -WarningAction SilentlyContinue).Exception.Response.StatusCode) -Force - - If ($err.StatusCode -eq 500){ - Write-Host "$($err.StatusCode) - $($err.message) - Most likely because no picture exists." -ForegroundColor Red - } else { - Write-Host "$($err.StatusCode) - $($err.message)" -ForegroundColor Red - } - Return + $msg = "$($err.StatusCode) - $($err.message)" + $msg += ": $(($query_params + $body_params) | ConvertTo-Json -Compress)" + Write-Error $msg + $myErrors += $msg + $msg = $null + } + catch [VerkadaRestMethodException] { + $msg = $_.ToString() + $msg += ": $(($query_params + $body_params) | ConvertTo-Json -Compress)" + Write-Error $msg + $myErrors += $msg + $msg = $null } - } #end process end { - + if ($errorsToFile.IsPresent){ + if (![string]::IsNullOrEmpty($myErrors)){ + Get-Date | Out-File ./errors.txt -Append + $myErrors | Out-File ./errors.txt -Append + } + } } #end end } #end function \ No newline at end of file diff --git a/verkadaModule/Public/Test-VerkadaAccessProfilePictureUrl.ps1 b/verkadaModule/Public/Test-VerkadaAccessProfilePictureUrl.ps1 deleted file mode 100644 index 6c778b7..0000000 --- a/verkadaModule/Public/Test-VerkadaAccessProfilePictureUrl.ps1 +++ /dev/null @@ -1,106 +0,0 @@ -function Test-VerkadaAccessProfilePictureUrl{ - <# - .SYNOPSIS - Tests to see if the user profile picture URL is valid; i.e. does the user have a profile picture. - - .DESCRIPTION - This function will test to see if the user profile picture url returns a 200 or a 404 to determine if the user specified has a profile picture. - The org_id and reqired tokens can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands. - - .LINK - https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Test-VerkadaAccessProfilePictureUrl.md - - .EXAMPLE - Test-VerkadaAccessProfilePictureUrl -userId '801c9551-b04c-4293-84ad-b0a6aa0588b3' -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_token 'a366ef47-2c20-4d35-a90a-10fd2aee113a' -x_verkada_auth 'auth-token-uuid-dscsdc' -usr 'a099bfe6-34ff-4976-9d53-ac68342d2b60' - This will test to see if a profile picture for the user with userId 801c9551-b04c-4293-84ad-b0a6aa0588b3 exists. The org_id and tokens are submitted as parameters in the call. - - .EXAMPLE - Read-VerkadaCommandUsers | Test-VerkadaAccessProfilePictureUrl - This will test to see if a profile picture for all the users in a organization exists. The org_id and tokens will be populated from the cached created by Connect-Verkada. - #> - [CmdletBinding(PositionalBinding = $true)] - [Alias("t-VrkdaAcPrflPicUrl")] - param ( - #The UUID of the user - [Parameter(ValueFromPipelineByPropertyName = $true)] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [Alias('user_id')] - [String]$userId, - #The email address of the user - [Parameter(ValueFromPipelineByPropertyName = $true)] - [String]$email, - #The first name of the user - [Parameter(ValueFromPipelineByPropertyName = $true)] - [Alias('first_name')] - [String]$firstName, - #The last name of the user - [Parameter(ValueFromPipelineByPropertyName = $true)] - [Alias('last_name')] - [String]$lastName, - #The UUID of the organization the user belongs to - [Parameter(ValueFromPipelineByPropertyName = $true)] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [String]$org_id = $Global:verkadaConnection.org_id, - #The Verkada(CSRF) token of the user running the command - [Parameter()] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [string]$x_verkada_token = $Global:verkadaConnection.csrfToken, - #The Verkada Auth(session auth) token of the user running the command - [Parameter()] - [ValidateNotNullOrEmpty()] - [string]$x_verkada_auth = $Global:verkadaConnection.userToken, - #The UUID of the user account making the request - [Parameter()] - [ValidateNotNullOrEmpty()] - [ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')] - [string]$usr = $Global:verkadaConnection.usr - ) - - begin { - #parameter validation - if ([string]::IsNullOrEmpty($org_id)) {throw "org_id is missing but is required!"} - if ([string]::IsNullOrEmpty($x_verkada_token)) {throw "x_verkada_token is missing but is required!"} - if ([string]::IsNullOrEmpty($x_verkada_auth)) {throw "x_verkada_auth is missing but is required!"} - if ([string]::IsNullOrEmpty($usr)) {throw "usr is missing but is required!"} - } #end begin - - process { - if ([string]::IsNullOrEmpty($userId)){ - Write-Error "userId required" - return - } - $url = "https://vcerberus.command.verkada.com/user/photos/$org_id/$userId/128.jpg" - $res = @{} - try { - Invoke-VerkadaCommandCall -url $url -org_id $org_Id -x_verkada_token $x_verkada_token -x_verkada_auth $x_verkada_auth -usr $usr -method GET -body '' | Out-Null - $res.userId = $userId - $res.email = $email - $res.firstName = $firstName - $res.lastName = $lastName - $res.profilePicture = $true - - $response = $res | ConvertTo-Json -Depth 100 | ConvertFrom-Json - return $response - } - catch [Microsoft.PowerShell.Commands.HttpResponseException] { - $res.userId = $userId - $res.email = $email - $res.firstName = $firstName - $res.lastName = $lastName - $res.profilePicture = $false - - $response = $res | ConvertTo-Json -Depth 100 | ConvertFrom-Json - return $response - } - catch { - $_.Exception - } - } #end process - - end { - - } #end end -} #end function \ No newline at end of file diff --git a/verkadaModule/verkadaModule.psd1 b/verkadaModule/verkadaModule.psd1 index 2d83586..7c6ebc9 100644 --- a/verkadaModule/verkadaModule.psd1 +++ b/verkadaModule/verkadaModule.psd1 @@ -3,7 +3,7 @@ # # Generated by: Verkada SE Community # -# Generated on: 05/13/2025 +# Generated on: 5/13/2025 # @{ @@ -69,28 +69,26 @@ PowerShellVersion = '6.1' # NestedModules = @() # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. -FunctionsToExport = 'Add-VerkadaAccessBadgeToUser', 'Add-VerkadaAccessGroup', - 'Add-VerkadaAccessSiteAdmin', 'Add-VerkadaAccessUser', +FunctionsToExport = 'Add-VerkadaAccessGroup', 'Add-VerkadaAccessSiteAdmin', 'Add-VerkadaAccessUserCard', 'Add-VerkadaAccessUserLicensePlate', - 'Add-VerkadaAccessUserPin', 'Add-VerkadaAccessUserToGroup', 'Add-VerkadaCamera', 'Add-VerkadaCommandSite', 'Add-VerkadaCommandUser', 'Add-VerkadaLicensePlateOfInterest', 'Add-VerkadaWorkplaceEmployee', 'Connect-Verkada', 'Disable-VerkadaAccessUserCard', 'Disable-VerkadaAccessUserLicensePlate', 'Disconnect-Verkada', 'Enable-VerkadaAccessUserCard', - 'Enable-VerkadaAccessUserLicensePlate', - 'Export-VerkadaAccessUserProfilePicture', 'Find-VerkadaCommandUser', + 'Enable-VerkadaAccessUserLicensePlate', 'Find-VerkadaCommandUser', 'Find-VerkadaUserId', 'Get-Otp', 'Get-VerkadaAccessCredential', 'Get-VerkadaAccessDoorConfigReport', 'Get-VerkadaAccessDoors', 'Get-VerkadaAccessDoorSchedules', 'Get-VerkadaAccessGroup', 'Get-VerkadaAccessLevels', 'Get-VerkadaAccessSite', - 'Get-VerkadaAccessUser', 'Get-VerkadaAccessUserReport', - 'Get-VerkadaAccessUserViaGraphql', 'Get-VerkadaAlarmsDevices', - 'Get-VerkadaAlarmsSiteConfig', 'Get-VerkadaAlarmsSiteContacts', - 'Get-VerkadaCameraConfig', 'Get-VerkadaCameraGroup', - 'Get-VerkadaCameras', 'Get-VerkadaCloudBackupSettings', - 'Get-VerkadaCommandUser', 'Get-VerkadaLicensePlatesOfInterest', + 'Get-VerkadaAccessUser', 'Get-VerkadaAccessUserProfilePicture', + 'Get-VerkadaAccessUserReport', 'Get-VerkadaAccessUserViaGraphql', + 'Get-VerkadaAlarmsDevices', 'Get-VerkadaAlarmsSiteConfig', + 'Get-VerkadaAlarmsSiteContacts', 'Get-VerkadaCameraConfig', + 'Get-VerkadaCameraGroup', 'Get-VerkadaCameras', + 'Get-VerkadaCloudBackupSettings', 'Get-VerkadaCommandUser', + 'Get-VerkadaLicensePlatesOfInterest', 'Get-VerkadaWorkplaceEmployee', 'Read-VerkadaAccessEntities', 'Read-VerkadaAccessGroups', 'Read-VerkadaAccessSchedules', 'Read-VerkadaAccessUsers', 'Read-VerkadaAlarmsSites', @@ -135,15 +133,17 @@ AliasesToExport = 'a-VrkdaAcGrp', 'Add-VrkdaAcGrp', 'a-VrkdaAcUsrCrd', 'Add-VrkdaWrkEmp', 'd-VrkdaAcUsrCrd', 'Disable-VrkdaAcUsrCrd', 'd-VrkdaAcUsrLPR', 'Disable-VrkdaAcUsrLPR', 'e-VrkdaAcUsrCrd', 'Enable-VrkdaAcUsrCrd', 'e-VrkdaAcUsrLPR', 'Enable-VrkdaAcUsrLPR', - 'ep-VrkdaAcUsrPrflPic', 'Export-VrkdaAcUsrPrflPic', 'otp', - 'Get-VrkdaAcGrp', 'gt-VrkdaAcGrp', 'Get-VrkdaAcUsr', 'gt-VrkdaAcUsr', - 'g-VrkdAlrmDevs', 'Get-VrkdAlrmDevs', 'Get-VerkadaCameraSite', - 'Get-VrkdaCmdUsr', 'gt-VrkdaCmdUsr', 'Get-VerkadaLPoI', - 'Get-VrkdaWrkEmp', 'gt-VrkdaWrkEmp', 'rd-VrkdaAcGrps', - 'Read-VrkdaAcGrps', 'rd-VrkdaCamArchv', 'Read-VrkdaCamArchv', - 'rd-VrkdaGstSte', 'Read-VrkdaGstSte', 'rd-VrkdaWrkEmp', - 'Read-VrkdaWrkEmp', 'Remove-VrkdaAcGrp', 'rm-VrkdaAcGrp', - 'Remove-VrkdaAcUsrBtUnlk', 'rm-VrkdaAcUsrBtUnlk', + 'otp', 'Get-VrkdaAcGrp', 'gt-VrkdaAcGrp', 'Get-VrkdaAcUsr', + 'gt-VrkdaAcUsr', 'ep-VrkdaAcUsrPrflPic', + 'Export-VerkadaAccessUserProfilePicture', + 'Export-VrkdaAcUsrPrflPic', 'g-VrkdaAcUsrPrflPic', + 'Get-VrkdaAcUsrPrflPic', 'g-VrkdAlrmDevs', 'Get-VrkdAlrmDevs', + 'Get-VerkadaCameraSite', 'Get-VrkdaCmdUsr', 'gt-VrkdaCmdUsr', + 'Get-VerkadaLPoI', 'Get-VrkdaWrkEmp', 'gt-VrkdaWrkEmp', + 'rd-VrkdaAcGrps', 'Read-VrkdaAcGrps', 'rd-VrkdaCamArchv', + 'Read-VrkdaCamArchv', 'rd-VrkdaGstSte', 'Read-VrkdaGstSte', + 'rd-VrkdaWrkEmp', 'Read-VrkdaWrkEmp', 'Remove-VrkdaAcGrp', + 'rm-VrkdaAcGrp', 'Remove-VrkdaAcUsrBtUnlk', 'rm-VrkdaAcUsrBtUnlk', 'Remove-VrkdaAcUsrCrd', 'rm-VrkdaAcUsrCrd', 'Remove-VrkdaAcUsrEntryCo', 'rm-VrkdaAcUsrEntryCo', 'Remove-VrkdaAcUsrFrGrp', 'rm-VrkdaAcUsrFrGrp',