PSSmartsheet.psm1

#Region '.\Public\Authentication\Initialize-SmartsheetClient.ps1' 0
Function Initialize-SmartsheetClient {
<#
    .SYNOPSIS
        Creates a Smartsheet Client Object that you can use to make API calls and sets it to the default
     
    .DESCRIPTION
        Creates a Smartsheet Client Object that you can use to make API calls and sets it to the default
     
    .PARAMETER AccessToken
        A description of the AccessToken parameter.
     
    .PARAMETER AssumedUser
        The email address of a member of your Org that you want to impersonate.
        NOTE: You must have Sys Admin privileges to use this.
     
    .PARAMETER CustomURI
        Use this Param if you are interacting with a custom intance of Smartsheet.
        NOTE: Intended for internal use only
     
    .PARAMETER DefaultURI
        Use this switch if you are interacting with them main Smartsheet app
     
    .PARAMETER Gov
        Use this switch if you are interacting with Smartsheet Gov
     
    .EXAMPLE
        Initialize-SmartsheetClient -AccessToken 'll352u9jujauoqz4gstvsae05'
     
    .EXAMPLE
        Initialize-SmartsheetClient -AccessToken 'll352u9jujauoqz4gstvsae05' -AssumedUser 'john.doe@example.com'
 
    .Example
        Initialize-SmartsheetClient -AccessToken 'll352u9jujauoqz4gstvsae05' -Gov
 
#>

    
    [CmdletBinding(DefaultParameterSetName = 'DefaultURI')]
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '', Justification='Param used for ParameterSetName matching')]
    Param
    (
        [Parameter(Mandatory = $true)]
        [string]
        $AccessToken,
        [string]
        $AssumedUser,
        [Parameter(ParameterSetName = 'CustomURI',
                   DontShow = $true)]
        [ValidatePattern('http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?')]
        [String]
        $CustomURI,
        [Parameter(ParameterSetName = 'DefaultURI')]
        [Switch]
        $DefaultURI,
        [Parameter(ParameterSetName = 'GovURI')]
        [switch]
        $Gov
    )
    
    Process {
        Switch ($PSCmdlet.ParameterSetName) {
            "DefaultURI" {
                $client = [Smartsheet.Api.SmartsheetBuilder]::new().SetAccessToken($AccessToken)
            }
            "GovURI" {
                $client = [Smartsheet.Api.SmartsheetBuilder]::new().SetAccessToken($AccessToken).SetBaseURI([Smartsheet.Api.SmartsheetBuilder]::GOV_BASE_URI)
            }
            "CustomURI" {
                $client = [Smartsheet.Api.SmartsheetBuilder]::new().SetAccessToken($AccessToken).SetBaseURI($CustomURI)
            }
        }
        
        If (![string]::IsNullOrWhiteSpace($AssumedUser)) {
            [Void]$Client.SetAssumedUser($AssumedUser)
        }
        Try {
            [Void]$client.Build().UserResources.GetCurrentUser()
            $script:SmartsheetClient = $Client.Build()
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Authentication\Initialize-SmartsheetClient.ps1' 89
#Region '.\Public\Cells\Get-SmartsheetCellHistory.ps1' 0
Function Get-SmartsheetCellHistory {
<#
    .SYNOPSIS
        Gets the cell modification history.
     
    .DESCRIPTION
        Gets the cell modification history for a specified cell.
     
    .PARAMETER SheetID
        Sheet Id of the sheet being accessed.
     
    .PARAMETER RowID
        Row Id in the sheet being accessed.
     
    .PARAMETER ColumnID
        Column Id in the sheet being accessed.
     
    .PARAMETER Includes
        A comma-separated list of elements to include in the query.
     
    .EXAMPLE
        Get-SmartsheetCellHistory -SheetID '9283173393803140' -RowID '0123456789012345' -ColumnID '4567890123456789,'
     
    .NOTES
        This is a resource-intensive operation and incurs 10 additional requests against the rate limit.
#>

    
    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $SheetID,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $RowID,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $ColumnID,
        [ValidateNotNullOrEmpty()]
        [Smartsheet.Api.Models.CellInclusion[]]
        $Includes = $null
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
        $PagingParams = [Smartsheet.Api.Models.PaginationParameters]::new($true, $null, $null)
    }
    Process {
        Try {
            $Script:SmartsheetClient.SheetResources.RowResources.CellResources.GetCellHistory(
                $SheetID,
                $RowID,
                $ColumnID,
                $Includes,
                $PagingParams
            )
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Cells\Get-SmartsheetCellHistory.ps1' 74
#Region '.\Public\Columns\Add-SmartsheetColumn.ps1' 0
Function Add-SmartsheetColumn {
<#
    .SYNOPSIS
        Inserts one or more columns into the sheet specified.
     
    .DESCRIPTION
        Inserts one or more columns into the sheet specified.
     
    .PARAMETER SheetId
        The ID of the sheet to add columns to.
     
    .PARAMETER Column
        One or more column objects to add to the specified sheet.
     
    .EXAMPLE
        $column1 = New-SSColumnObject -Title "Column 1" -Primary
        $column2 = New-SSColumnObject -Title "Second Column" -Type CHECKBOX
        Add-SmartsheetColumn -SheetId '2252168947361668' -Column $column1,$Column2
     
    .NOTES
        If multiple columns are specified in the request, the index attribute must be set to the same value for all columns.
#>

    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $SheetId,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [Smartsheet.Api.Models.Column[]]
        $Column
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        Try {
            $script:SmartsheetClient.SheetResources.ColumnResources.AddColumns(
                $SheetId,
                $Column
            )
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Columns\Add-SmartsheetColumn.ps1' 58
#Region '.\Public\Columns\Get-SmartsheetColumn.ps1' 0
Function Get-SmartsheetColumn {
<#
    .SYNOPSIS
        Gets a specified column or a list of columns on a specified sheet
     
    .DESCRIPTION
        Gets a specified column or a list of columns on a specified sheet
     
    .PARAMETER SheetID
        Sheet Id of the sheet being accessed.
     
    .PARAMETER Include
        Represents specific elements to include in a response.
     
    .PARAMETER ColumnID
        Column Id in the sheet being accessed.
     
    .PARAMETER Level
        Specifies whether new functionality, such as multi-contact data is returned in a backwards-compatible, text format (level=0, default), multi-contact data (level=1), or multi-picklist data (level=2).
     
    .EXAMPLE
        Get-SmartsheetColumn -SheetID '9283173393803140'
     
    .EXAMPLE
        Get-SmartsheetColumn -SheetID '9283173393803140' -ColumnID '7960873114331012'
     
#>

    [CmdletBinding()]
    [OutputType([Smartsheet.Api.Models.Column])]
    Param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $SheetID,
        [Smartsheet.Api.Models.ColumnInclusion[]]
        $Include = $null,
        [ValidateNotNullOrEmpty()]
        [long[]]
        $ColumnID,
        [ValidateSet('0', '1', '2')]
        [int]
        $Level = 0
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
        $PagingParams = [Smartsheet.Api.Models.PaginationParameters]::new($true, $null, $null)
    }
    Process {
        Try {
            If ($ColumnID) {
                ForEach ($column In $ColumnID) {
                    $Script:SmartsheetClient.SheetResources.ColumnResources.getColumn(
                        $SheetID,
                        $column,
                        $Include
                    )
                }
            }
            Else {
                $Script:SmartsheetClient.SheetResources.ColumnResources.ListColumns(
                    $SheetID,
                    $Include,
                    $PagingParams,
                    $level
                ).data
            }
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Columns\Get-SmartsheetColumn.ps1' 82
#Region '.\Public\Columns\Remove-SmartsheetColumn.ps1' 0
Function Remove-SmartsheetColumn {
<#
    .SYNOPSIS
        Deletes a specified column.
     
    .DESCRIPTION
        Deletes a specified column.
     
    .PARAMETER SheetId
        The ID of the sheet to delete columns from
     
    .PARAMETER ColumnId
        The ID of the column(s) to delete from the specified sheet.
     
    .PARAMETER Force
        Forces the rows to be deleted without prompting.
     
    .EXAMPLE
        Remove-SmartsheetColumn -SheetId '9283173393803140' -ColumnId '0123456789012345' -Force
     
#>

    [CmdletBinding(ConfirmImpact = 'High',
                   SupportsShouldProcess = $true)]
    Param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $SheetId,
        [Parameter(Mandatory = $true,
                   ValueFromPipeline = $true)]
        [ValidateNotNullOrEmpty()]
        [long[]]
        $ColumnId,
        [switch]
        $Force
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        Try {
            ForEach ($ID In $ColumnId) {
                $Column = Get-SmartsheetColumn -SheetId $SheetId -ColumnId $ID
                If ($Force -or $pscmdlet.ShouldProcess("The column $($Column.title) will be deleted. This cannot be undone")) {
                    $Script:SmartsheetClient.SheetResources.ColumnResources.DeleteColumn(
                        $SheetId,
                        $Column.Id
                    )
                }
            }
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Columns\Remove-SmartsheetColumn.ps1' 66
#Region '.\Public\Columns\Set-SmartsheetColumn.ps1' 0
Function Set-SmartsheetColumn {
<#
    .SYNOPSIS
        Updates properties of the column, moves the column, and/or renames the column.
     
    .DESCRIPTION
        Updates properties of the column, moves the column, and/or renames the column.
     
    .PARAMETER SheetId
        The sheet containing the column to update.
     
    .PARAMETER Column
        A column object representing the column to update. Must include an ID for the specified column.
     
    .EXAMPLE
        $column = New-SSColumnObject -Title "Column 1" -Id '5005385858869124' -Index 0
        Set-SmartsheetColumn -SheetId '2252168947361668' -Column $column
     
    .NOTES
        You cannot change the type of a Primary column.
        While dependencies are enabled on a sheet, you can't change the type of any special calendar/Gantt columns.
        If the column type is changed, all cells in the column are converted to the new column type and column validation is cleared.
        Type is optional when moving or renaming, but required when changing type or dropdown values.
#>

    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $SheetId,
        [Parameter(Mandatory = $true,
                   ValueFromPipeline = $true)]
        [ValidateNotNullOrEmpty()]
        [Smartsheet.Api.Models.Column]
        $Column
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        Try {
            $script:SmartsheetClient.SheetResources.ColumnResources.UpdateColumn(
                $SheetId,
                $Column
            )
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Columns\Set-SmartsheetColumn.ps1' 61
#Region '.\Public\Groups\Add-SmartsheetGroup.ps1' 0
Function Add-SmartsheetGroup {
<#
    .SYNOPSIS
        Creates a new Group
     
    .DESCRIPTION
        Creates a new Group
     
    .PARAMETER GroupObject
        The group object created using New-SSGroupObject
     
    .PARAMETER Name
        Name of the group to create.
        NOTE: Must be unique accross org
     
    .PARAMETER Description
        A description of the new group to create
     
    .PARAMETER MemberEmail
        Email address(es) of user(s) to initially populate the new group with.
     
    .EXAMPLE
        $Group = New-SSGroupObject -Name 'A new Group' -MemberEmail 'john.doe@example.com','Jane.doe@example.com'
        Add-SmartsheetGroup -GroupObject $Group
     
    .EXAMPLE
        Add-SmartsheetGroup -Name 'A new Group' -Description 'A description of the group' -MemberEmail 'john.doe@example.com','Jane.doe@example.com'
     
    .NOTES
        This operation is only available to group administrators and system administrators.
#>

    
    [CmdletBinding(DefaultParameterSetName = 'Params')]
    Param
    (
        [Parameter(ParameterSetName = 'GroupObject',
                   ValueFromPipeline = $true)]
        [Alias('InputObject')]
        [Smartsheet.Api.Models.Group[]]
        $GroupObject,
        [Parameter(ParameterSetName = 'Params',
                   Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [string]
        $Name,
        [Parameter(ParameterSetName = 'Params')]
        [string]
        $Description = $null,
        [Parameter(ParameterSetName = 'Params')]
        [ValidatePattern('^[^@\s]+@[^@\s]+\.[^@\s]+$')]
        [string[]]
        $MemberEmail
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        If ($PSCmdlet.ParameterSetName -eq 'Params') {
            If ($MemberEmail) {
                $GroupObject = New-SSGroupObject -Name $Name -Description $Description -MemberEmail $MemberEmail
            }
            Else {
                $GroupObject = New-SSGroupObject -Name $Name -Description $Description
            }
            
        }
        ForEach ($GO In $GroupObject) {
            Try {
                $script:SmartsheetClient.GroupResources.CreateGroup($GO)
            }
            Catch {
                If ($ErrorActionPreference -eq 'Stop') {
                    $PSCmdlet.ThrowTerminatingError($_)
                }
                Else {
                    Write-Error $_
                }
            }
        }
    }
}
#EndRegion '.\Public\Groups\Add-SmartsheetGroup.ps1' 85
#Region '.\Public\Groups\Add-SmartsheetGroupMember.ps1' 0
Function Add-SmartsheetGroupMember {
<#
    .SYNOPSIS
        Adds one or more members to a group.
     
    .DESCRIPTION
        Adds one or more members to a group.
     
    .PARAMETER Email
        Email address of new user(s) to add to the specified group
     
    .PARAMETER GroupID
        ID of the group to add members to.
     
    .EXAMPLE
        Add-SmartsheetGroupMembers -Email 'john.doe@example.com','Jane.doe@example.com' -GroupID '7917992160847748'
     
    .NOTES
        This operation is only available to group administrators and system administrators.
#>

    
    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory = $true)]
        [ValidatePattern('^[^@\s]+@[^@\s]+\.[^@\s]+$')]
        [string[]]
        $Email,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $GroupID
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        [Smartsheet.Api.Models.GroupMember[]]$groupMembers = $Email.foreach{
            [Smartsheet.Api.Models.GroupMember+AddGroupMemberBuilder]::new($_).Build()
        }
        Try {
            $script:SmartsheetClient.GroupResources.AddGroupMembers(
                $GroupID,
                $groupMembers
            )
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Groups\Add-SmartsheetGroupMember.ps1' 60
#Region '.\Public\Groups\Get-SmartsheetGroup.ps1' 0
Function Get-SmartsheetGroup {
<#
    .SYNOPSIS
        Retrieves information about a specified group or a list of all groups in the org.
     
    .DESCRIPTION
        Retrieves information about a specified group or a list of all groups in the org. When specifying a specific group, an array of group memebers is also returned.
     
    .PARAMETER GroupID
        The group ID of a specific group
     
    .EXAMPLE
        Get-SmartsheetGroup
     
    .EXAMPLE
        Get-SmartsheetGroup -GroupID '6932724448552836'
     
#>

    
    [CmdletBinding()]
    [OutputType([Smartsheet.Api.Models.Group])]
    Param
    (
        [Parameter(ValueFromPipeline = $true)]
        [ValidateNotNullOrEmpty()]
        [long[]]
        $GroupID
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
        $PagingParams = [Smartsheet.Api.Models.PaginationParameters]::new($true, $null, $null)
    }
    Process {
        If ($GroupID) {
            ForEach ($group In $GroupID) {
                Try {
                    $script:SmartsheetClient.GroupResources.GetGroup($group)
                }
                Catch {
                    If ($ErrorActionPreference -eq 'Stop') {
                        $PSCmdlet.ThrowTerminatingError($_)
                    }
                    Else {
                        Write-Error $_
                    }
                }
            }
        }
        Else {
            Try {
                $script:SmartsheetClient.GroupResources.ListGroups($PagingParams).Data
            }
            Catch {
                If ($ErrorActionPreference -eq 'Stop') {
                    $PSCmdlet.ThrowTerminatingError($_)
                }
                Else {
                    Write-Error $_
                }
            }
        }
    }
}
#EndRegion '.\Public\Groups\Get-SmartsheetGroup.ps1' 67
#Region '.\Public\Groups\Remove-SmartsheetGroup.ps1' 0
Function Remove-SmartsheetGroup {
<#
    .SYNOPSIS
        Deletes the group specified
     
    .DESCRIPTION
        Deletes the group specified
     
    .PARAMETER GroupID
        The ID of the group to delete
     
    .PARAMETER Force
        Removes group without prompting
     
    .EXAMPLE
        Remove-SmartsheetGroup -GroupID '6932724448552836' -Force
     
    .NOTES
        This operation is only available to group administrators and system administrators.
#>

    
    [CmdletBinding(ConfirmImpact = 'High',
                   SupportsShouldProcess = $true)]
    Param
    (
        [Parameter(Mandatory = $true,
                   ValueFromPipeline = $true)]
        [long[]]
        $GroupID,
        [switch]
        $Force
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        ForEach ($ID In $GroupID) {
            Try {
                $GroupObj = Get-SmartsheetGroup -GroupID $ID
                If ($Force -or $pscmdlet.ShouldProcess("Group $($GroupObj.Name) will be deleted. This cannot be undone")) {
                    $Script:SmartsheetClient.GroupResources.DeleteGroup(
                    $GroupObj.ID)
                }
            }
            Catch {
                If ($ErrorActionPreference -eq 'Stop') {
                    $PSCmdlet.ThrowTerminatingError($_)
                }
                Else {
                    Write-Error $_
                }
            }
        }
    }
}
#EndRegion '.\Public\Groups\Remove-SmartsheetGroup.ps1' 59
#Region '.\Public\Groups\Remove-SmartsheetGroupMember.ps1' 0
Function Remove-SmartsheetGroupMember {
<#
    .SYNOPSIS
        Removes specified member(s) from a group.
     
    .DESCRIPTION
        Removes specified member(s) from a group.
     
    .PARAMETER GroupID
        Id of the group to remove users from
     
    .PARAMETER User
        The userID or email of the user to be removed from the group
     
    .PARAMETER Force
        Removes user(s) group the specified group without prompting
     
    .EXAMPLE
        Remove-SmartsheetGroupMember -GroupID '7917992160847748' -UserID '1539725208119172' -Force
     
    .NOTES
        This operation is only available to group administrators and system administrators.
#>

    
    [CmdletBinding(ConfirmImpact = 'Medium',
                   SupportsShouldProcess = $true)]
    Param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $GroupID,
        [Parameter(Mandatory = $true,
                   ValueFromPipeline = $true)]
        [ValidateNotNullOrEmpty()]
        [Alias('Email', 'UserID')]
        [string[]]
        $User,
        [switch]
        $Force
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        $GroupObj = Get-SmartsheetGroup -GroupID $GroupID
        ForEach ($U In $User) {
            Try {
                If ($U -match "^[^@\s]+@[^@\s]+\.[^@\s]+$") {
                $UserObj = Get-SmartsheetUser -Email $U
                }
                Else {
                    $UserObj = (Get-SmartsheetUser -UserID $U)
                }
                If ($Force -or $pscmdlet.ShouldProcess("Removing user with email $($UserObj.Email) from $($GroupObj.Name)")) {
                    $script:SmartsheetClient.GroupResources.RemoveGroupMember(
                        $GroupID,
                        $UserObj.ID
                    )
                }
            }
            Catch {
                If ($ErrorActionPreference -eq 'Stop') {
                    $PSCmdlet.ThrowTerminatingError($_)
                }
                Else {
                    Write-Error $_
                }
            }
        }
    }
}
#EndRegion '.\Public\Groups\Remove-SmartsheetGroupMember.ps1' 76
#Region '.\Public\Groups\Set-SmartsheetGroup.ps1' 0
Function Set-SmartsheetGroup {
<#
    .SYNOPSIS
        Updates the Group specified
     
    .DESCRIPTION
        Updates the Group Specified.
     
    .PARAMETER GroupObject
        The group object created using New-SSGroupObject
     
    .PARAMETER GroupID
        The ID of the group to update
     
    .PARAMETER Name
        A new name for the group. Must be unique accross the org.
     
    .PARAMETER Description
        A new description for the group
     
    .PARAMETER OwnerID
        The userID of a user to transfer ownership to.
        NOTE: Must be either a Group Admin or System Admin
     
    .EXAMPLE
        $Group = New-SSGroupObject -GroupId '2331373580117892' -Name 'New Group Name' -OwnerID '2331373580117892'
        Set-SmartsheetGroup -GroupObject $group
     
    .EXAMPLE
        New-SSGroupObject -GroupId '2331373580117892' -Name 'New Group Name' -OwnerID '2331373580117892' | Set-SmartsheetGroup
     
    .NOTES
        This operation is only available to group administrators and system administrators.
#>

    
    [CmdletBinding(DefaultParameterSetName = 'Params')]
    Param
    (
        [Parameter(ParameterSetName = 'GroupObject',
                   Mandatory = $true,
                   ValueFromPipeline = $true)]
        [ValidateNotNullOrEmpty()]
        [Alias('InputObject')]
        [Smartsheet.Api.Models.Group[]]
        $GroupObject,
        [Parameter(ParameterSetName = 'Params',
                   Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $GroupID,
        [Parameter(ParameterSetName = 'Params')]
        [ValidateNotNullOrEmpty()]
        [string]
        $Name,
        [Parameter(ParameterSetName = 'Params')]
        [string]
        $Description,
        [Parameter(ParameterSetName = 'Params')]
        [ValidateNotNullOrEmpty()]
        [long]
        $OwnerID
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        If ($PSCmdlet.ParameterSetName -eq 'Params') {
            $GroupObject = New-SSGroupObject -GroupID $GroupID
            $PSBoundParameters.Keys.Where{
                $_ -ne 'GroupID'
            }.Foreach{
                $GroupObject.$_ = $PSBoundParameters[$_]
            }
        }
        ForEach ($GO In $GroupObject) {
            Try {
                $script:SmartsheetClient.GroupResources.UpdateGroup($GO)
            }
            Catch {
                If ($ErrorActionPreference -eq 'Stop') {
                    $PSCmdlet.ThrowTerminatingError($_)
                }
                Else {
                    Write-Error $_
                }
            }
        }
    }
}
#EndRegion '.\Public\Groups\Set-SmartsheetGroup.ps1' 93
#Region '.\Public\Helpers\New-SSCellHyperlink.ps1' 0
Function New-SSCellHyperlinkObject {
<#
    .SYNOPSIS
        Builds a hyperlink object to a URL, a sheet, or a report.
     
    .DESCRIPTION
        Builds a hyperlink object to a URL, a sheet, or a report.
     
    .PARAMETER ReportId
        The ID of a report to link to.
     
    .PARAMETER SheetId
        The ID of a sheet to link to.
     
    .PARAMETER SightId
        The ID of a sight/dashboard to link to.
     
    .PARAMETER URL
        A URL to link to.
     
    .EXAMPLE
        $HyperLink = New-SSCellHyperlinkObject -URL 'https://smartsheet-platform.github.io/api-docs/'
        $Cell = New-SSCellObject -ColumnId '7518312134403972' -HyperLink $HyperLink
     
    .NOTES
        If no parameters are specified, object will reset a hyperlink.
#>

    
    [CmdletBinding(DefaultParameterSetName = 'URL')]
    [OutputType([Smartsheet.Api.Models.Hyperlink])]
    Param
    (
        [Parameter(ParameterSetName = 'Report')]
        [ValidateNotNullOrEmpty()]
        [long]
        $ReportId,
        [Parameter(ParameterSetName = 'Sheet')]
        [ValidateNotNullOrEmpty()]
        [long]
        $SheetId,
        [Parameter(ParameterSetName = 'Sight')]
        [ValidateNotNullOrEmpty()]
        [long]
        $SightId,
        [Parameter(ParameterSetName = 'URL')]
        [ValidatePattern('http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?')]
        [ValidateNotNullOrEmpty()]
        [string]
        $URL
    )
    
    $HyperlinkObj = [Smartsheet.Api.Models.Hyperlink]::new()
    $PSBoundParameters.Keys.ForEach{
        $HyperlinkObj.$_ = $PSBoundParameters[$_]
    }
    $HyperlinkObj
}
#EndRegion '.\Public\Helpers\New-SSCellHyperlink.ps1' 58
#Region '.\Public\Helpers\New-SSCellLinkObject.ps1' 0
Function New-SSCellLinkObject {
<#
    .SYNOPSIS
        Builds a CellLink object that can be added to a cell object
     
    .DESCRIPTION
        Builds a CellLink object that can be added to a cell object to link data from a cell in one sheet to a cell in another sheet.
     
    .PARAMETER ColumnId
        The ColumnId of the cell to link
     
    .PARAMETER RowId
        The RowId of the cell to link
     
    .PARAMETER SheetId
        The SheetId of the cell to link
     
    .EXAMPLE
        $CellLink = New-SSCellLinkObject -ColumnId '1888812600190852' -RowId '6572427401553796' -SheetId '2068827774183300'
        $Cell = New-SSCellObject -ColumnId '7518312134403972' -LinkInFromCell $CellLink
     
    .NOTES
        A given row or cell update operation may contain only link updates, or no link updates.
        Attempting to mix row/cell updates with cell link updates results in error code 1115.
        Additionally, a CellLink object can only be added to an existing cell, so the cell.linkInFromCell attribute is not allowed when POSTing a new row to a sheet.
#>

    
    [CmdletBinding()]
    [OutputType([Smartsheet.Api.Models.CellLink])]
    Param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $ColumnId,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $RowId,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $SheetId
    )
    
    $CellLink = [Smartsheet.Api.Models.CellLink]::new()
    $PSBoundParameters.Keys.ForEach{
        $CellLink.$_ = $PSBoundParameters[$_]
    }
    $CellLink
}
#EndRegion '.\Public\Helpers\New-SSCellLinkObject.ps1' 52
#Region '.\Public\Helpers\New-SSCellObject.ps1' 0
Function New-SSCellObject {
<#
    .SYNOPSIS
        Builds a new cell object that can be used to create or update rows in sheets
     
    .DESCRIPTION
        Builds a new cell object that can be used to create or update rows in sheets
     
    .PARAMETER ColumnID
        The Id of the column that the cell is located in
     
    .PARAMETER Value
        A string, a number, or a Boolean value
     
    .PARAMETER OverrideValidation
        (Admin only) Indicates whether the cell value can contain a value outside of the validation limits (value = true).
     
    .PARAMETER Hyperlink
        A hyperlink to a URL, sheet, reportor dashboard.
        When used, the 'Value' parameter can be a string or null. If null:
        If the hyperlink is a URL link, the cell's value is set to the URL itself.
        If the hyperlink is a dashboard, report, or sheet link, the cell's value is set to the dashboard, report, or sheet name.
     
    .PARAMETER LinkInFromCell
        An inbound link from a cell in another sheet. This cell's value mirrors the linked cell's value.
     
    .EXAMPLE
        $Cell = New-SSCellObject -ColumnId '5005385858869124'
     
#>

    
    [CmdletBinding()]
    [OutputType([Smartsheet.Api.Models.Cell])]
    Param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $ColumnID,
        [AllowNull()]
        [object]
        $Value = $null,
        [Parameter(DontShow = $true)]
        [switch]
        $OverrideValidation,
        [Parameter(ParameterSetName = 'Hyperlink')]
        [ValidateNotNullOrEmpty()]
        [Smartsheet.Api.Models.Hyperlink]
        $Hyperlink,
        [Parameter(ParameterSetName = 'CellLink')]
        [ValidateNotNullOrEmpty()]
        [Alias('CellLink')]
        [Smartsheet.Api.Models.CellLink]
        $LinkInFromCell
    )
    
    Process {
        If ($PSCmdlet.ParameterSetName -eq 'CellLink') {
            $Value = $null
        }
        $CellObject = [Smartsheet.Api.Models.Cell+AddCellBuilder]::new(
            $ColumnID,
            $Value
        ).Build()
        $PSBoundParameters.Keys.ForEach{
            $CellObject.$_ = $PSBoundParameters[$_]
        }
        $CellObject
    }
}
#EndRegion '.\Public\Helpers\New-SSCellObject.ps1' 71
#Region '.\Public\Helpers\New-SSColumnObject.ps1' 0
Function New-SSColumnObject {
<#
    .SYNOPSIS
        Builds a Smartsheet Column Object
     
    .DESCRIPTION
        Builds a Smartsheet Column Object that can be used to add or update columns on a sheet
     
    .PARAMETER Title
        The title of the column. Required if the column is new.
     
    .PARAMETER Description
        The description of the column.
     
    .PARAMETER Index
        Column index or position. Defaults to '0'. If multiple columns are added to a sheet, the index attribute must be set to the same value for all columns. Columns are inserted into the sheet starting at the specified position (index), in the sequence that the columns appear in the request.
     
    .PARAMETER Type
        The type used for the column. Defaults to "TEXT_NUMBER".
     
    .PARAMETER Primary
        Indicates if the column will be the "Primary" column of the sheet.
        NOTE: The praimary column can only have a type of "TEXT_NUMBER". A sheet can only have 1 primary column.
     
    .PARAMETER ID
        The ID of a column to update.
     
    .PARAMETER Hidden
        Indicates if the column will be hidden.
     
    .PARAMETER SystemColumnType
        System columns represent data that is filled in by Smartsheet and whose values cannot be changed by the user.
     
    .PARAMETER Width
        The display width of the column in pixels.
     
    .EXAMPLE
        $column1 = New-SSColumnObject -Title "Column 1" -Primary
     
    .EXAMPLE
        $Column = New-SSColumnObject -Title 'New Column Name' -Id '1888812600190852'
#>

    
    [CmdletBinding(DefaultParameterSetName = 'RegularColumn')]
    Param
    (
        [ValidateNotNullOrEmpty()]
        [string]
        $Title,
        [AllowNull()]
        [AllowEmptyString()]
        [string]
        $Description,
        [int]
        $Index = 0,
        [Parameter(ParameterSetName = 'RegularColumn')]
        [ValidateNotNullOrEmpty()]
        [Alias('ColumnType')]
        [Smartsheet.Api.Models.ColumnType]
        $Type = "TEXT_NUMBER",
        [Parameter(ParameterSetName = 'RegularColumn')]
        [switch]
        $Primary,
        [Alias('ColumnID')]
        [long]
        $ID,
        [switch]
        $Hidden,
        [Parameter(ParameterSetName = 'SystemColumn')]
        [Smartsheet.Api.Models.SystemColumnType]
        $SystemColumnType,
        [ValidateNotNullOrEmpty()]
        [long]
        $Width
    )
    
    $ColumnObject = [Smartsheet.Api.Models.Column]::new()
    $PSBoundParameters.Keys.ForEach{
        $ColumnObject.$_ = $PSBoundParameters[$_]
    }
    $ColumnObject
    
}
#EndRegion '.\Public\Helpers\New-SSColumnObject.ps1' 84
#Region '.\Public\Helpers\New-SSGroupObject.ps1' 0
Function New-SSGroupObject {
<#
    .SYNOPSIS
        Creates a Group object that can be used to add memebers to a group
     
    .DESCRIPTION
        Creates a Group object that can be used to add memebers to a group
     
    .PARAMETER MemberEmail
        Email addresses of user to initially populate a new group
     
    .PARAMETER Name
        A name for the group. Must be unique within the org
     
    .PARAMETER Description
        A description of the group
     
    .PARAMETER GroupID
        The ID of the group to update
     
    .PARAMETER OwnerID
        The userID of a user to transfer ownership to.
        NOTE: Must be either a Group Admin or System Admin
     
    .EXAMPLE
        $Group = New-SSGroupObject -Name 'A new Group' -MemberEmail 'john.doe@example.com','Jane.doe@example.com'
     
    .EXAMPLE
        $Group = New-SSGroupObject -GroupId '2331373580117892' -Name 'New Group Name' -OwnerID '2331373580117892'
     
#>

    
    [CmdletBinding(DefaultParameterSetName = 'New')]
    [OutputType([Smartsheet.Api.Models.Group])]
    Param
    (
        [Parameter(ParameterSetName = 'New')]
        [ValidatePattern('^[^@\s]+@[^@\s]+\.[^@\s]+$')]
        [Alias('Email')]
        [string[]]
        $MemberEmail,
        [Parameter(ParameterSetName = 'New',
                   Mandatory = $true)]
        [Parameter(ParameterSetName = 'Update')]
        [string]
        $Name,
        [string]
        $Description = $null,
        [Parameter(ParameterSetName = 'Update',
                   Mandatory = $true)]
        [long]
        $GroupID,
        [Parameter(ParameterSetName = 'Update')]
        [long]
        $OwnerID
    )
    Process {
        Switch ($PsCmdlet.ParameterSetName) {
            'New' {
                $GroupObject = [Smartsheet.Api.Models.Group+CreateGroupBuilder]::new($Name, $Description)
                If ($MemberEmail) {
                    [Smartsheet.Api.Models.GroupMember[]]$groupMembers = $MemberEmail.foreach{
                        [Smartsheet.Api.Models.GroupMember+AddGroupMemberBuilder]::new($_).Build()
                    }
                    $GroupObject.SetMembers($groupMembers)
                }
                $GroupObject.Build()
                Break
            }
            'Update' {
                $GroupObject = [Smartsheet.Api.Models.Group+UpdateGroupBuilder]::new($GroupID)
                Switch ($PSBoundParameters.Keys) {
                    'Name' {
                        $GroupObject.SetName($Name)
                    }
                    'Description' {
                        $GroupObject.SetDescription($Description)
                    }
                    'OwnerID' {
                        $GroupObject.SetOwnerId($OwnerID)
                    }
                }
                $GroupObject.Build()
                Break
            }
        }
    }    
}
#EndRegion '.\Public\Helpers\New-SSGroupObject.ps1' 89
#Region '.\Public\Helpers\New-SSRowObject.ps1' 0
Function New-SSRowObject {
<#
    .SYNOPSIS
        Builds a row object used to add or update a row on a sheet.
     
    .DESCRIPTION
        Builds a row object used to add or update a row on a sheet.
     
    .PARAMETER Cells
        Cell objects to add or update in the row
     
    .PARAMETER ToTop
        Adds or moves the row to the top of the sheet
     
    .PARAMETER ToBottom
        Adds or moves the row to the bottom of the sheet
     
    .PARAMETER ParentId
        Adds or moves the row to the first child of the specified Id.
     
    .PARAMETER SiblingId
        Adds or moves the row to the next location below the the specified row at same hierarchical level.
        Can be paried with "Above" to place above the specified row.
     
    .PARAMETER Above
        When specified, adds or moves the row above the row specified in "SiblingId" at the same hierarchical level
     
    .PARAMETER Expanded
        Indicates whether the row is expanded or collapsed.
     
    .PARAMETER Locked
        Indicates that the row will be locked.
     
    .PARAMETER Indent
        The number of times to indent the row
     
    .PARAMETER Outdent
        The number of times to outdent the row
     
    .PARAMETER Id
        Id of a row to update
     
    .EXAMPLE
        $Cell1 = New-SSCellObject -ColumnId '7960873114331012' -Value $true
        $Cell2 = New-SSCellObject -ColumnId '642523719853956' -Value "Enabled"
        $Row1 = NewSSRowObject -ToBottom -Cells $Cell1,$Cell2
     
#>

    
    [CmdletBinding()]
    [OutputType([Smartsheet.Api.Models.Row])]
    Param
    (
        [ValidateNotNullOrEmpty()]
        [Smartsheet.Api.Models.Cell[]]
        $Cells,
        [switch]
        $ToTop,
        [switch]
        $ToBottom,
        [ValidateNotNullOrEmpty()]
        [long]
        $ParentId,
        [ValidateNotNullOrEmpty()]
        [long]
        $SiblingId,
        [switch]
        $Above,
        [switch]
        $Expanded,
        [switch]
        $Locked,
        [int]
        $Indent,
        [int]
        $Outdent,
        [ValidateNotNullOrEmpty()]
        [Alias('RowId')]
        [long]
        $Id
    )
    
    Process {
        $RowObj = [Smartsheet.Api.Models.Row]::new()
        $PSBoundParameters.Keys.ForEach{
            $RowObj.$_ = $PSBoundParameters[$_]
        }
        $RowObj
    }
}
#EndRegion '.\Public\Helpers\New-SSRowObject.ps1' 91
#Region '.\Public\Helpers\New-SSUserObject.ps1' 0
Function New-SSUserObject {
<#
    .SYNOPSIS
        Builds a Smartsheet User Object
     
    .DESCRIPTION
        Builds a Smartsheet User Object that can be used to add or update a user.
     
    .PARAMETER Email
        User's primary email address.
     
    .PARAMETER ID
        A description of the ID parameter.
     
    .PARAMETER FirstName
        User's first name.
     
    .PARAMETER LastName
        User's last name.
     
    .PARAMETER LicensedSheetCreator
        Indicates whether the user is a licensed user (can create and own sheets).
     
    .PARAMETER Admin
        Indicates whether the user is a system admin (can manage user accounts and organization account).
     
    .PARAMETER GroupAdmin
        Indicates whether the user is a group admin (can create and edit groups).
     
    .PARAMETER ResourceViewer
        Indicates whether the user is a resource viewer (can access resource views).
     
    .EXAMPLE
        New-SSUserObject -Email "test@example.com" -LicensedSheetCreator
         
        Returns a user object with the email of "test@example.com" that will be a licensed sheet creator that can be fed to Add-SmartsheetUser creating the account.
     
#>

    
    [CmdletBinding(DefaultParameterSetName = 'NewUserObject')]
    [OutputType([Smartsheet.Api.Models.User])]
    Param
    (
        [Parameter(ParameterSetName = 'NewUserObject',
                   Mandatory = $true)]
        [string]
        $Email,
        [Parameter(ParameterSetName = 'UpdateUserObject',
                   Mandatory = $true)]
        [long]
        $ID,
        [string]
        $FirstName,
        [string]
        $LastName,
        [Alias('Licensed')]
        [switch]
        $LicensedSheetCreator = $false,
        [Alias('IsAdmin')]
        [switch]
        $Admin,
        [switch]
        $GroupAdmin,
        [switch]
        $ResourceViewer
    )
    
    Process {
        If ($PSCmdlet.ParameterSetName -eq 'NewUserObject') {
            $userObj = [Smartsheet.Api.Models.User+AddUserBuilder]::new($null, $false, $false).Build()
        }
        ElseIf ($PSCmdlet.ParameterSetName -eq 'UpdateUserObject') {
            $userObj = [Smartsheet.Api.Models.User+UpdateUserBuilder]::new($null, $false, $false).Build()
        }
        $PSBoundParameters.Keys.ForEach{
            $userObj.$_ = $PSBoundParameters[$_]
        }
        $userObj
    }
}

    
#EndRegion '.\Public\Helpers\New-SSUserObject.ps1' 83
#Region '.\Public\Rows\Add-SmartsheetRow.ps1' 0
Function Add-SmartsheetRow {
<#
    .SYNOPSIS
        Inserts one or more rows into the sheet specified.
     
    .DESCRIPTION
        Inserts one or more rows into the sheet specified.
     
    .PARAMETER SheetId
        The Id of the sheet to add rows to.
     
    .PARAMETER Rows
        One or more Row Objects to add to the specified sheet.
     
    .EXAMPLE
        $Cell1 = New-SSCellObject -ColumnId '7960873114331012' -Value $true
        $Cell2 = New-SSCellObject -ColumnId '642523719853956' -Value "Enabled"
        $Cell3 = New-SSCellObject -ColumnID '7960873114331012' -Value $false
        $Row1 = NewSSRowObject -ToBottom -Cells $Cell1,$Cell2
        $Row2 = NewSSRowObject -ToTop -Cells $Cell3
        Add-SmartsheetRow -SheetId '2331373580117892' -Rows $Row1,$Row2
     
    .NOTES
        Column Ids must be valid for the sheet to which the row belongs, and must only be used once for each row in the operation.
        Cells of a project sheet in the "Finish Date" column cannot be updated via API.
        Cells of a project sheet in the "Start Date" column cannot be updated via API for rows that contain a value in the "Predecessor" column.
        Max length for a cell value is 4000 characters after which truncation occurs without warning. Empty string values are converted to null.
        Calculation errors or problems with a formula do not cause the API call to return an error code. Instead, the response contains the same value as in the UI, such as cell.value = "#CIRCULAR REFERENCE".
#>

    
    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $SheetId,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [Smartsheet.Api.Models.Row[]]
        $Rows
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        Try {
            $Script:SmartsheetClient.SheetResources.RowResources.AddRows(
                $SheetId,
                $Rows
            )
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Rows\Add-SmartsheetRow.ps1' 66
#Region '.\Public\Rows\Copy-SmartsheetRow.ps1' 0
Function Copy-SmartsheetRow {
<#
    .SYNOPSIS
        Copies the specified rows from one sheet to another.
     
    .DESCRIPTION
        Copies the specified rows from one sheet to another.
     
    .PARAMETER Source
        The ID of the sheet to copy rows from.
     
    .PARAMETER Destination
        The ID of the sheet to copy rows to.
     
    .PARAMETER Rows
        The ID of the row(s) to copy from the source sheet to the destination sheet.
     
    .PARAMETER Include
        A comma-separated list of row elements to copy in addition to the cell data
     
    .EXAMPLE
        Copy-SmartsheetRow -Source '4583173393803140' -Destination '2258256056870788' -Rows '145417762563972','8026717110462340'
     
#>

    
    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [Alias('CopyFrom')]
        [long]
        $Source,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [Alias('CopyTo')]
        [long]
        $Destination,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long[]]
        $Rows,
        [ValidateNotNullOrEmpty()]
        [Smartsheet.Api.Models.CopyRowInclusion[]]
        $Include = $null
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        Try {
            $DestinationObj = [Smartsheet.Api.Models.CopyOrMoveRowDestination]::new()
            $DestinationObj.SheetId = $Destination
            
            $DirectiveObj = [Smartsheet.Api.Models.CopyOrMoveRowDirective]::new()
            $DirectiveObj.RowIds = $Rows
            $DirectiveObj.To = $DestinationObj
            
            $script:SmartsheetClient.SheetResources.RowResources.CopyRowsToAnotherSheet(
                $Source,
                $DirectiveObj,
                $Include,
                $true
            )
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Rows\Copy-SmartsheetRow.ps1' 79
#Region '.\Public\Rows\Get-SmartsheetRow.ps1' 0
Function Get-SmartsheetRow {
<#
    .SYNOPSIS
        Retrieves the specified row
     
    .DESCRIPTION
        Retrieves the specified row
     
    .PARAMETER SheetID
        Sheet Id of the sheet being accessed.
     
    .PARAMETER RowID
        Row Id in the sheet being accessed.
     
    .PARAMETER Include
        A comma-separated list of elements to include in the response.
     
    .PARAMETER Exclude
        A comma-separated list of optional elements to not include in the response
     
    .EXAMPLE
        Get-SmartsheetRow -SheetID '4583173393803140' -RowID '2361756178769796'
     
#>

    
    [CmdletBinding()]
    [OutputType([Smartsheet.Api.Models.Row])]
    Param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $SheetID,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $RowID,
        [ValidateNotNullOrEmpty()]
        [Smartsheet.Api.Models.RowInclusion[]]
        $Include = $null,
        [ValidateNotNullOrEmpty()]
        [Smartsheet.Api.Models.RowExclusion[]]
        $Exclude = $null
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        Try {
            $script:SmartsheetClient.SheetResources.RowResources.GetRow(
                $SheetID,
                $RowID,
                $Include,
                $Exclude
            )
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Rows\Get-SmartsheetRow.ps1' 70
#Region '.\Public\Rows\Move-SmartsheetRow.ps1' 0
Function Move-SmartsheetRow {
<#
    .SYNOPSIS
        Moves the specified rows from one sheet to another.
     
    .DESCRIPTION
        Moves the specified rows from one sheet to another.
     
    .PARAMETER Source
        The ID of the sheet to move rows from.
     
    .PARAMETER Destination
        The ID of the sheet to move rows to.
     
    .PARAMETER Rows
        The ID of the row(s) to move from the source sheet to the destination sheet.
     
    .PARAMETER Include
        A comma-separated list of row elements to move in addition to the cell data
     
    .EXAMPLE
        Move-SmartsheetRow -Source '4583173393803140' -Destination '2258256056870788' -Rows '145417762563972','8026717110462340'
     
#>

    
    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [Alias('MoveFrom')]
        [long]
        $Source,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [Alias('MoveTo')]
        [long]
        $Destination,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long[]]
        $Rows,
        [ValidateNotNullOrEmpty()]
        [Smartsheet.Api.Models.MoveRowInclusion[]]
        $Include = $null
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        Try {
            $DestinationObj = [Smartsheet.Api.Models.CopyOrMoveRowDestination]::new()
            $DestinationObj.SheetId = $Destination
            
            $DirectiveObj = [Smartsheet.Api.Models.CopyOrMoveRowDirective]::new()
            $DirectiveObj.RowIds = $Rows
            $DirectiveObj.To = $DestinationObj
            
            $script:SmartsheetClient.SheetResources.RowResources.MoveRowsToAnotherSheet(
                $Source,
                $DirectiveObj,
                $Include,
                $true
            )
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Rows\Move-SmartsheetRow.ps1' 79
#Region '.\Public\Rows\Remove-SmartsheetRow.ps1' 0
Function Remove-SmartsheetRow {
<#
    .SYNOPSIS
        Deletes one or more rows from the sheet specified.
     
    .DESCRIPTION
        Deletes one or more rows from the sheet specified.
     
    .PARAMETER SheetId
        The ID of the sheet to remove rows from
     
    .PARAMETER RowIds
        The ID of the row(s) to delete from the specified sheet.
     
    .PARAMETER Force
        Deletes the specified rows without prompting
     
    .EXAMPLE
        Remove-SmartsheetRow -SheetId '2252168947361668' -RowIds '207098194749316','207098194749317' -Force
     
    .NOTES
        This operation deletes ALL child rows of the specified row.
#>

    
    [CmdletBinding(ConfirmImpact = 'High',
                   SupportsShouldProcess = $true)]
    Param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $SheetId,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long[]]
        $RowIds,
        [switch]
        $Force
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        Try {
            If ($Force -or $pscmdlet.ShouldProcess("$($RowIds.count) rows will be deleted. This cannot be undone")) {
                $Script:SmartsheetClient.SheetResources.RowResources.DeleteRows(
                    $SheetId,
                    $RowIds,
                    $true
                )
            }
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Rows\Remove-SmartsheetRow.ps1' 66
#Region '.\Public\Rows\Set-SmartsheetRow.ps1' 0
Function Set-SmartsheetRow {
<#
    .SYNOPSIS
        Updates one or more rows into the sheet specified.
     
    .DESCRIPTION
        Updates one or more rows into the sheet specified.
     
    .PARAMETER SheetId
        The Id of the sheet to Update rows in.
     
    .PARAMETER Rows
        One or more Row Objects to update on the specified sheet.
     
    .EXAMPLE
        $Cell1 = New-SSCellObject -ColumnId '7960873114331012' -Value $false
        $Cell2 = New-SSCellObject -ColumnId '642523719853956' -Value "Disabled"
        $Row = NewSSRowObject -Id '6572427401553796' -Cells $Cell1,$Cell2
        Set-SmartsheetRow -SheetId '2068827774183300' -Rows $Row
     
    .NOTES
        Column Ids must be valid for the sheet to which the row belongs, and must only be used once for each row in the operation.
        Cells of a project sheet in the "Finish Date" column cannot be updated via API.
        Cells of a project sheet in the "Start Date" column cannot be updated via API for rows that contain a value in the "Predecessor" column.
        Max length for a cell value is 4000 characters after which truncation occurs without warning. Empty string values are converted to null.
        Calculation errors or problems with a formula do not cause the API call to return an error code. Instead, the response contains the same value as in the UI, such as cell.value = "#CIRCULAR REFERENCE".
#>

    
    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $SheetId,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [Smartsheet.Api.Models.Row[]]
        $Rows
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        Try {
            $Script:SmartsheetClient.SheetResources.RowResources.UpdateRows(
                $SheetId,
                $Rows
            )
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Rows\Set-SmartsheetRow.ps1' 64
#Region '.\Public\Search\Search-SmartsheetSheet.ps1' 0
Function Search-SmartsheetSheet {
<#
    .SYNOPSIS
        Searches for the specified text in a sheet.
     
    .DESCRIPTION
        Searches for the specified text in a sheet. By default will search all sheets the user has access two unless a sheetID is specified
     
    .PARAMETER Query
        Text with which to perform the search.
     
    .PARAMETER SheetID
        Sheet Id of the sheet being searched
     
    .EXAMPLE
        Search-SmartsheetSheets -Query 'Stuff'
     
#>

    
    [CmdletBinding()]
    [OutputType([Smartsheet.Api.Models.SearchResult])]
    Param
    (
        [Parameter(Mandatory = $true)]
        [string]
        $Query,
        [long]
        $SheetID
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        Try {
            If ($SheetID) {
                $Script:SmartsheetClient.SearchResources.SearchSheet(
                    $SheetID,
                    $Query
                )
            }
            Else {
                $script:SmartsheetClient.SearchResources.Search($Query)
            }
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Search\Search-SmartsheetSheet.ps1' 58
#Region '.\Public\Sheets\Add-SmartsheetSheet.ps1' 0
Function Add-SmartsheetSheet {
<#
    .SYNOPSIS
        Creates a sheet from scratch
     
    .DESCRIPTION
        Creates a sheet from scratch in either the user's "Sheets" folder, or the specified folder or workspace
     
    .PARAMETER Name
        The name for the new sheet.
     
    .PARAMETER Column
        One or more column objects built using New-SSColumnObject.
     
    .PARAMETER WorkspaceID
        The ID of a workspace to create the sheet in.
     
    .PARAMETER FolderID
        The ID of a folder to create the sheet in.
     
    .EXAMPLE
        $column1 = New-SSColumnObject -Title "Column 1" -Primary
        $column2 = New-SSColumnObject -Title "Second Column" -Type CHECKBOX
        Add-SmartsheetSheet -Column $column1,$column2
     
#>

    
    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory = $true)]
        [Alias('Title')]
        [string]
        $Name,
        [Parameter(Mandatory = $true)]
        [Smartsheet.Api.Models.Column[]]
        $Column,
        [Parameter(ParameterSetName = 'Workspace')]
        [long]
        $WorkspaceID,
        [Parameter(ParameterSetName = 'Folder')]
        [long]
        $FolderID
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
        $NewSheet = [Smartsheet.Api.Models.Sheet+CreateSheetBuilder]::($Name,$Column).Build()
    }
    Process {
        Try {
            If ($PsCmdlet.ParameterSetName -eq 'Workspace') {
                $Script:SmartsheetClient.WorkspaceResources.SheetResources.CreateSheet(
                    $WorkspaceID,
                    $NewSheet
                )
            }
            ElseIf ($PsCmdlet.ParameterSetName -eq 'Folder') {
                $Script:SmartsheetClient.FolderResources.SheetResources.CreateSheet(
                    $FolderID,
                    $NewSheet
                )
            }
            Else {
                $Script:SmartsheetClient.SheetResources.CreateSheet(
                    $NewSheet
                )
            }
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }

    }
}
#EndRegion '.\Public\Sheets\Add-SmartsheetSheet.ps1' 83
#Region '.\Public\Sheets\Add-SmartsheetSheetFromTemplate.ps1' 0
Function Add-SmartsheetSheetFromTemplate {
<#
    .SYNOPSIS
        Creates a sheet from a template
     
    .DESCRIPTION
        Creates a sheet from a template in either the user's "Sheets" folder, or the specified folder or workspace
     
    .PARAMETER Name
        Name of the new sheet
     
    .PARAMETER FromID
        Template Id from which to create the sheet.
     
    .PARAMETER Includes
        Additional parameter to create a sheet from template. A comma-separated list of elements to copy from the template.
     
    .PARAMETER WorkspaceID
        Workspace Id where the sheet will be created
     
    .PARAMETER FolderID
        Folder Id where the sheet will be created
     
    .EXAMPLE
        Add-SmartsheetSheetFromTemplate -Title "A new sheet" -FromID '7679398137620356' -Include ATTACHMENTS,DISCUSSIONS
     
#>

    
    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory = $true)]
        [Alias('Title')]
        [string]
        $Name,
        [Parameter(Mandatory = $true)]
        [Alias('CopyFrom', 'TemplateID')]
        [long]
        $FromID,
        [Smartsheet.Api.Models.TemplateInclusion[]]
        $Includes = $null,
        [Parameter(ParameterSetName = 'Workspace')]
        [long]
        $WorkspaceID,
        [Parameter(ParameterSetName = 'Folder')]
        [long]
        $FolderID
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
        $NewSheet = [Smartsheet.Api.Models.Sheet+CreateSheetFromTemplateBuilder]::New($Name, $FromID).Build()
    }
    Process {
        Try {
            If ($PsCmdlet.ParameterSetName -eq 'Workspace') {
                $Script:SmartsheetClient.WorkspaceResources.SheetResources.CreateSheetFromTemplate(
                    $WorkspaceID,
                    $NewSheet,
                    $Includes
                )
            }
            ElseIf ($PsCmdlet.ParameterSetName -eq 'Folder') {
                $Script:SmartsheetClient.FolderResources.SheetResources.CreateSheetFromTemplate(
                    $FolderID,
                    $NewSheet,
                    $Includes
                )
            }
            Else {
                $Script:SmartsheetClient.SheetResources.CreateSheetFromTemplate(
                    $NewSheet,
                    $Includes
                )
            }
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Sheets\Add-SmartsheetSheetFromTemplate.ps1' 89
#Region '.\Public\Sheets\Copy-SmartsheetSheet.ps1' 0
Function Copy-SmartsheetSheet {
<#
    .SYNOPSIS
        Creates a copy of the specified sheet.
     
    .DESCRIPTION
        Creates a copy of the specified sheet.
     
    .PARAMETER SheetID
        Sheet Id of the sheet being copied
     
    .PARAMETER DestinationID
        Id of the destination container (when copying or moving a folder or a sheet). Required if destinationType is "folder" or "workspace" If destinationType is "home", this value must be null.
     
    .PARAMETER DestinationType
        Type of the destination container (when copying or moving a folder or a sheet). One of the following values:
        folder
        home
        workspace
     
    .PARAMETER NewName
        Name of the newly created sheet
     
    .PARAMETER Includes
        A comma-separated list of elements to copy
     
    .EXAMPLE
        Copy-SmartsheetSheet -SheetID '9283173393803140' -DestinationID '3791509922310020' -DestinationType FOLDER -NewName 'A copy of sheet 1'
     
    .EXAMPLE
        Copy-SmartsheetSheet -SheetID '9283173393803140' -NewName 'Another copy of a sheet' -Includes DATA
     
#>

    
    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory = $true)]
        [long]
        $SheetID,
        [Parameter(Mandatory = $false)]
        [AllowNull()]
        [long]
        $DestinationID = $null,
        [Smartsheet.Api.Models.DestinationType]
        $DestinationType = "HOME",
        [Parameter(Mandatory = $true)]
        [string]
        $NewName,
        [Smartsheet.Api.Models.SheetCopyInclusion[]]
        $Includes = $null
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        $Destination = [Smartsheet.Api.Models.ContainerDestination]::new()
        $Destination.DestinationId = $DestinationID
        $Destination.DestinationType = $DestinationType
        $Destination.NewName = $NewName
        
        Try {
            $script:SmartsheetClient.SheetResources.CopySheet(
                $SheetID,
                $Destination,
                $Includes
            )
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Sheets\Copy-SmartsheetSheet.ps1' 82
#Region '.\Public\Sheets\Get-SmartsheetSheet.ps1' 0
<#
    .SYNOPSIS
        Retrieves a list of sheets
     
    .DESCRIPTION
        Retrieves a list of sheets. By default this will be sheets the calling user has access to, but if the user is a system administrator they can use the "ListOrgSheets" switch to list all sheets owned by members of the organization.
     
    .PARAMETER ListOrgSheets
        Gets a summarized list of all sheets owned by the members of the organization account.
        NOTE: This operation is only available to system administrators
     
    .PARAMETER ModifiedSince
        When specified with a date and time value, response only includes the objects that are modified on or after the date and time specified. If you need to keep track of frequent changes, it may be more useful to use Read-SmartsheetSheet and reference the 'Version' property.
     
    .PARAMETER Include
        A comma-separated list of optional elements to include in the respons.
     
    .EXAMPLE
        Get-SmartsheetSheet
     
    .EXAMPLE
        Get-SmartsheetSheet -ListOrgSheets
 
#>

Function Get-SmartsheetSheet {
    [CmdletBinding(DefaultParameterSetName = 'Individual')]
    [OutputType([Smartsheet.Api.Models.Sheet[]])]
    Param
    (
        [Parameter(ParameterSetName = 'FullOrg')]
        [switch]
        $ListOrgSheets,
        [datetime]
        $ModifiedSince = $null,
        [Parameter(ParameterSetName = 'Individual')]
        [ValidateNotNullOrEmpty()]
        [Smartsheet.Api.Models.SheetInclusion[]]
        $Include = $null
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
        $PagingParams = [Smartsheet.Api.Models.PaginationParameters]::new($true, $null, $null)
    }
    Process {
        Try {
            If ($ListOrgSheets) {
                $Script:SmartsheetClient.UserResources.SheetResources.ListOrgSheets(
                    $PagingParams,
                    $ModifiedSince
                ).data
            }
            Else {
                $cript:SmartsheetClient.SheetResources.ListSheets(
                    $Include,
                    $PagingParams,
                    $ModifiedSince
                ).data
            }
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Sheets\Get-SmartsheetSheet.ps1' 73
#Region '.\Public\Sheets\Move-SmartsheetSheet.ps1' 0
Function Move-SmartsheetSheet {
<#
    .SYNOPSIS
        Moves the specified sheet to a new location.
     
    .DESCRIPTION
        Moves the specified sheet to a new location. When a sheet that is shared to one or more users and/or groups is moved into or out of a workspace, those sheet-level shares are preserved.
     
    .PARAMETER SheetID
        Sheet Id of the sheet being accessed.
     
    .PARAMETER DestinationID
        Id of the destination container (when copying or moving a folder or a sheet). Required if destinationType is "folder" or "workspace" If destinationType is "home", this value must be null.
     
    .PARAMETER DestinationType
        Type of the destination container (when copying or moving a folder or a sheet). One of the following values:
        folder
        home
        workspace
     
    .EXAMPLE
        Move-SmartsheetSheet -SheetID '9283173393803140' -DestinationID '3791509922310020' -DestinationType FOLDER
     
    .EXAMPLE
        Move-SmartsheetSheet -SheetID '9283173393803140'
     
#>

    
    [CmdletBinding()]
    Param
    (
        [long]
        $SheetID,
        [Parameter(ParameterSetName = 'DestinationSpecified',
                   Mandatory = $true)]
        [AllowNull()]
        [long]
        $DestinationID = $null,
        [Parameter(ParameterSetName = 'DestinationSpecified',
                   Mandatory = $true)]
        [Smartsheet.Api.Models.DestinationType]
        $DestinationType = "HOME"
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        $Destination = [Smartsheet.Api.Models.ContainerDestination]::new()
        $Destination.DestinationId = $DestinationID
        $Destination.DestinationType = $DestinationType
        
        Try {
            $script:SmartsheetClient.SheetResources.MoveSheet(
                $SheetID,
                $Destination
            )
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Sheets\Move-SmartsheetSheet.ps1' 71
#Region '.\Public\Sheets\Read-SmartsheetSheet.ps1' 0
Function Read-SmartsheetSheet {
<#
    .SYNOPSIS
        Gets the sheet specified by SheetID. Returns the sheet, including rows, and optionally populated with discussion and attachment objects.
     
    .DESCRIPTION
        Gets the sheet specified by SheetID. Returns the sheet, including rows, and optionally populated with discussion and attachment objects.
     
    .PARAMETER SheetID
        Sheet Id of the sheet being accessed.
     
    .PARAMETER Include
        A comma-separated list of optional elements to include in the response
     
    .PARAMETER Exclude
        A comma-separated list of optional elements to not include in the response
     
    .PARAMETER ColumnIDs
        A comma-separated list of column ids. The response contains only the specified columns in the "columns" array, and individual rows' "cells" array only contains cells in the specified columns.
     
    .PARAMETER RowIds
        A comma-separated list of row Ids on which to filter the rows included in the result.
     
    .PARAMETER RowNumbers
        A comma-separated list of row numbers on which to filter the rows included in the result. Non-existent row numbers are ignored.
     
    .EXAMPLE
        Read-SmartsheetSheet -SheetID '4583173393803140'
     
    .EXAMPLE
        Read-SmartsheetSheet -SheetID '4583173393803140' -Include FILTERS,DISCUSSIONS -Exclude NONEXISTANTCELLS
#>

    
    [CmdletBinding()]
    [OutputType([Smartsheet.Api.Models.Sheet])]
    Param
    (
        [Parameter(Mandatory = $true,
                   ValueFromPipeline = $true)]
        [ValidateNotNullOrEmpty()]
        [long]
        $SheetID,
        [ValidateNotNullOrEmpty()]
        [Smartsheet.Api.Models.SheetLevelInclusion[]]
        $Include = $null,
        [ValidateNotNullOrEmpty()]
        [Smartsheet.Api.Models.SheetLevelExclusion[]]
        $Exclude = $null,
        [long[]]
        $ColumnIDs = $null,
        [long[]]
        $RowIds = $null,
        [int[]]
        $RowNumbers = $null
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
        
    }
    Process {
        Try {
            $script:SmartsheetClient.SheetResources.GetSheet(
                $SheetID,
                $Include,
                $Exclude,
                $RowIds,
                $RowNumbers,
                $ColumnIDs,
                $null,
                $null
            )
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Sheets\Read-SmartsheetSheet.ps1' 86
#Region '.\Public\Sheets\Remove-SmartsheetSheet.ps1' 0
Function Remove-SmartsheetSheet {
<#
    .SYNOPSIS
        Deletes a specified sheet.
     
    .DESCRIPTION
        Deletes a specified sheet. This cannot be undone!
     
    .PARAMETER SheetId
        The Id of the sheet(s) to delete.
     
    .PARAMETER Force
        Forces the sheet to be deleted without prompting
     
    .EXAMPLE
        Remove-SmartsheetSheet -SheetId 1531988831168388 -Force
     
#>

    
    [CmdletBinding(ConfirmImpact = 'High',
                   SupportsShouldProcess = $true)]
    Param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [long[]]
        $SheetId,
        [switch]
        $Force
    )
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        ForEach ($ID In $SheetId) {
            Try {
                $SheetObj = Get-SmartsheetSheet -SheetID $ID
                If ($Force -or $pscmdlet.ShouldProcess("The sheet $($SheetObj.Name) will be deleted. This cannot be undone")) {
                    $Script:SmartsheetClient.SheetResources.DeleteSheet(
                        $SheetObj.ID)
                }
            }
            Catch {
                If ($ErrorActionPreference -eq 'Stop') {
                    $PSCmdlet.ThrowTerminatingError($_)
                }
                Else {
                    Write-Error $_
                }
            }
        }
    }
}
#EndRegion '.\Public\Sheets\Remove-SmartsheetSheet.ps1' 56
#Region '.\Public\Users\Add-SmartsheetUser.ps1' 0
Function Add-SmartsheetUser {
<#
    .SYNOPSIS
        Adds a user to the organization account.
     
    .DESCRIPTION
        Adds a user to the organization account.
     
    .PARAMETER UserObject
        One or more user objects created using New-SSUserObject.
     
    .PARAMETER sendEmail
        Indicates whether to send a welcome email. Defaults to false.
     
    .EXAMPLE
        $User = New-SSUserObject -Email "test@example.com" -LicensedSheetCreator
        Add-SmartsheetUser -UserObject $User
     
    .EXAMPLE
        $User1 = New-SSUserObject -Email "test@example.com" -LicensedSheetCreator
        $user2 = New-SSUserObject -Email "secondTest@example.com" -LicensedSheetCreator -Admin
        Add-SmartsheetUser -UserObject $User1,$user2
         
    .NOTES
        This operation is only available to system administrators
         
        If successful, and user auto provisioning (UAP) is on, and user matches the auto provisioning rules, user is added to the org.
        If UAP is off, or user does not match UAP rules, user is invited to the org and must explicitly accept the invitation to join.
         
        In some specific scenarios, supplied attributes such as firstName and lastName may be ignored.
        For example, if you are inviting an existing Smartsheet user to join your organization account, and the invited user has not yet accepted your invitation, any supplied firstName and lastName are ignored.
#>

    
    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory = $true,
                   ValueFromPipeline = $true)]
        [Alias('User')]
        [Smartsheet.Api.Models.User[]]
        $UserObject,
        [switch]
        $sendEmail
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        ForEach ($U In $UserObject) {
            If ([string]::IsNullOrEmpty($U.Email)) {
                Write-Error "No email address specified. Please set the Email property of the userobject with that of the user to add"
                Continue
            }
            Try {
                Write-Verbose "Adding user $($U.Email)"
                $script:SmartsheetClient.UserResources.AddUser($U,
                    $sendEmail.IsPresent,
                    $null
                )
                Write-Verbose "User $($U.Email) has been Added."
            }
            Catch {
                If ($ErrorActionPreference -eq 'Stop') {
                    $PSCmdlet.ThrowTerminatingError($_)
                }
                Else {
                    Write-Error $_
                }
            }
        }
    }
}
#EndRegion '.\Public\Users\Add-SmartsheetUser.ps1' 76
#Region '.\Public\Users\Get-SmartsheetUser.ps1' 0
Function Get-SmartsheetUser {
<#
    .SYNOPSIS
        Returns specified Smartsheet user or list of users
     
    .DESCRIPTION
        Returns the specified Smartsheet user or a list of users
     
    .PARAMETER UserID
        The ID of a specific user to get.
     
    .PARAMETER Email
        The email address or list of email addresses of users to get.
     
    .PARAMETER List
        Returns an array of all users in the org.
     
    .PARAMETER Me
        Returns a user object representing the calling user.
     
    .EXAMPLE
        Get-SmartsheetUsers -Email "John.Doe@example.com"
     
        Returns user info for a smartsheet user with the email of "John.Doe@exampled.com".
     
    .EXAMPLE
        Get-SmartsheetUsers -Email "John.Doe@example.com","Jane.Doe@example.com"
     
        Returns user info for both matching users
     
    .EXAMPLE
        Get-SmartsheetUsers -List
     
        Gets a list of users in the organization account.
     
    .EXAMPLE
        Get-SmartsheetUsers -Me
     
        Gets the current user.
     
    .OUTPUTS
        Smartsheet.Api.Models.User, Smartsheet.Api.Models.UserProfile, Smartsheet.Api.Models.User, Smartsheet.Api.Models.UserProfile
     
#>

    
    [CmdletBinding(DefaultParameterSetName = 'Me',
                   SupportsPaging = $true)]
    [OutputType([Smartsheet.Api.Models.UserProfile], ParameterSetName = 'Me')]
    [OutputType([Smartsheet.Api.Models.User], ParameterSetName = 'List')]
    [OutputType([Smartsheet.Api.Models.UserProfile], ParameterSetName = 'UserID')]
    [OutputType([Smartsheet.Api.Models.User], ParameterSetName = 'Email')]
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '', Justification='Param used for ParameterSetName matching')]
    Param
    (
        [Parameter(ParameterSetName = 'UserID')]
        [long]
        $UserID,
        [Parameter(ParameterSetName = 'Email')]
        [string[]]
        $Email,
        [Parameter(ParameterSetName = 'List')]
        [switch]
        $List,
        [Parameter(ParameterSetName = 'Me')]
        [switch]
        $Me
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
        $PagingParams = [Smartsheet.Api.Models.PaginationParameters]::new($true, $null, $null)
    }
    Process {
        Try {
            Switch ($PSCmdlet.ParameterSetName) {
                "UserID" {
                    $script:SmartSheetClient.UserResources.GetUser($UserID)
                }
                "Email" {
                    $Script:SmartsheetClient.UserResources.ListUsers($Email, $PagingParams).Data
                }
                
                "List" {
                    $Script:SmartsheetClient.UserResources.ListUsers($null, $PagingParams).Data
                }
                "Me" {
                    $script:SmartSheetClient.UserResources.GetCurrentUser()
                }
            }
        }
        Catch {
            If ($ErrorActionPreference -eq 'Stop') {
                $PSCmdlet.ThrowTerminatingError($_)
            }
            Else {
                Write-Error $_
            }
        }
    }
}
#EndRegion '.\Public\Users\Get-SmartsheetUser.ps1' 103
#Region '.\Public\Users\Remove-SmartsheetUser.ps1' 0
Function Remove-SmartsheetUser {
<#
    .SYNOPSIS
        Removes A Smartsheet User from an organization account
     
    .DESCRIPTION
        Removes a user from an organization account. User is transitioned to a free collaborator with read-only access to owned dashboards, reports, sheets, workspaces, and any shared templates (unless those are optionally transferred to another user).
     
    .PARAMETER User
        The userID or email of the user to be removed from the organization
     
    .PARAMETER RemoveFromSharing
        Switch to remove the user from sharing for all sheets/workspaces in the organization account. If not specified, user is not removed from sharing.
     
    .PARAMETER TransferTo
        The userID or email of the user to transfer ownership to. If the user being removed owns groups, they are transferred to this user.
        If the user owns sheets, and transferSheets is true, the removed user's sheets are transferred to this user.
        NOTE: Required if user owns groups
        NOTE: If the TransferTo parameter is specified and the removed user owns groups, the user specified via the TransferTo parameter must have group admin rights.
     
    .PARAMETER TransferSheets
        If set, the removed user's sheets are transferred to the user specified with the TransferTo parameter. Else, sheets are not transferred
     
    .PARAMETER Force
        Forces deletion of specified user without prompting
     
    .EXAMPLE
        Remove-SmartsheetUser -User 'Bad.Employee@example.com' -RemoveFromSharing
         
        Example
        Remove-SmartsheetUser -User '94094820842' -TransferTo 'John.Manager@example.com' -TransferSheets
     
    .NOTES
        This operation is only available to system administrators.
        The transferTo and transferSheets parameters cannot be specified for a user who has not yet accepted an invitation to join the organization account (that is, if user status=PENDING).
#>

    
    [CmdletBinding(DefaultParameterSetName = 'Transfer',
                   ConfirmImpact = 'High',
                   SupportsShouldProcess = $true)]
    Param
    (
        [Parameter(Mandatory = $true,
                   ValueFromPipeline = $true)]
        [ValidateNotNullOrEmpty()]
        [string[]]
        $User,
        [switch]
        $RemoveFromSharing,
        [Parameter(ParameterSetName = 'Transfer',
                   Mandatory = $false)]
        [Parameter(ParameterSetName = 'TransferSheets',
                   Mandatory = $true)]
        [string]
        $TransferTo,
        [Parameter(ParameterSetName = 'TransferSheets')]
        [switch]
        $TransferSheets,
        [switch]
        $Force
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        If (![String]::IsNullOrEmpty($TransferTo)) {
            If ($TransferTo -match "^[^@\s]+@[^@\s]+\.[^@\s]+$") {
                $TransferToObj = Get-SmartsheetUser -Email $TransferTo
            }
            Else {
                $TransferToObj = (Get-SmartsheetUser -UserID $TransferTo)
            }
            
        }
        ForEach ($U In $User) {
            If ($U -match "^[^@\s]+@[^@\s]+\.[^@\s]+$") {
                $UserObj = Get-SmartsheetUser -Email $U
            }
            Else {
                $UserObj = (Get-SmartsheetUser -UserID $U)
            }
            If ($Force -or $pscmdlet.ShouldProcess("Removing user with email $($UserObj.Email) from Org")) {
                Try {
                    If ($TransferToObj) {
                        $script:SmartsheetClient.UserResources.RemoveUser($userObj.ID,
                            $TransferToObj.ID,
                            $TransferSheets.IsPresent,
                            $RemoveFromSharing.IsPresent
                        )
                    }
                    Else {
                        $script:SmartsheetClient.UserResources.RemoveUser($userObj.ID,
                            $null,
                            $TransferSheets.IsPresent,
                            $RemoveFromSharing.IsPresent
                        )
                    }
                }
                Catch {
                    If ($ErrorActionPreference -eq 'Stop') {
                        $PSCmdlet.ThrowTerminatingError($_)
                    }
                    Else {
                        Write-Error $_
                    }
                }
            }
        }
    }
}
#EndRegion '.\Public\Users\Remove-SmartsheetUser.ps1' 114
#Region '.\Public\Users\Set-SmartsheetUser.ps1' 0
Function Set-SmartsheetUser {
<#
    .SYNOPSIS
        Updates a Smartsheet user
     
    .DESCRIPTION
        Updates a specified Smartsheet user account
     
    .PARAMETER UserObject
        A user object created with the New-SSUserObject cmdlet
     
    .EXAMPLE
        $User = New-SSUserObject -ID '82349925918590' -LicensedSheetCreator -Admin
        Set-SmartsheetUser -UserObject $user
     
#>

    
    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory = $true,
                   ValueFromPipeline = $true)]
        [Alias('User')]
        [Smartsheet.Api.Models.User[]]
        $UserObject
    )
    
    Begin {
        If ([String]::IsNullOrEmpty($Script:SmartsheetClient)) {
            Throw "Smartsheet API Client has not yet been initialized. Please run Initialize-SmartsheetClient and try again."
        }
    }
    Process {
        ForEach ($U In $UserObject) {
            If ([string]::IsNullOrEmpty($U.Id) -and ![string]::IsNullOrEmpty($U.Email)) {
                $U.Id = (Get-SmartsheetUser -Email $U.Email).Id
            }
            ElseIf ([string]::IsNullOrEmpty($U.Id) -and [string]::IsNullOrEmpty($U.Email)) {
                Write-Error "No UserID specified. Please set the ID property of the userobject with that of the user to update"
                Continue
            }
            Try {
                Write-Verbose "Updating user $($U.Id)"
                $script:SmartsheetClient.UserResources.UpdateUser($U)
                Write-Verbose "User $($U.Id) has been updated."
            }
            Catch {
                If ($ErrorActionPreference -eq 'Stop') {
                    $PSCmdlet.ThrowTerminatingError($_)
                }
                Else {
                    Write-Error $_
                }
            }
        }
    }
}
#EndRegion '.\Public\Users\Set-SmartsheetUser.ps1' 58