poshbox.psm1

<#
    .NOTES
    --------------------------------------------------------------------------------
     Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2019 v5.6.156
     Generated on: 1/6/2019 9:47 PM
     Generated by: whiggs
    --------------------------------------------------------------------------------
    .DESCRIPTION
        Script generated by PowerShell Studio 2019
#>



    <#
        ===========================================================================
         Created with: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.155
         Created on: 11/18/2018 11:55 AM
         Created by: whiggs
         Organization:
         Filename: poshbox.psm1
        -------------------------------------------------------------------------
         Module Name: poshbox
        ===========================================================================
    #>

    
    #.EXTERNALHELP .\en-US\poshbox.psm1-Help.xml
    
    function connect-box
    {
        [CmdletBinding(DefaultParameterSetName = 'reg')]
        param
        (
            [Parameter(ParameterSetName = 'file', Mandatory = $true)]
            [ValidatePattern('^([a-zA-Z]:\\|\\\\)(((?![<>:"/\\|?*]).)+((?<![ .])\\)?)*\.json$')]
            [ValidateScript({Test-Path $_ -PathType Leaf})]
            [String]$path,
            [ValidatePattern("\d{4,}")]
            [string]$id
        )
        If ($path)
        {
            If (Test-Path "HKCU:\Software\boxmodule")
            {
                Remove-Item "HKCU:\Software\boxmodule" -Force
            }
            New-Item "HKCU:\Software\boxmodule" -Force
            $json = Get-Content $path | ConvertFrom-Json
            Set-ItemProperty -Path "HKCU:\Software\boxmodule" -Name "enterpriseid" -Value $json.enterpriseID -Force
            Set-ItemProperty -Path "HKCU:\Software\boxmodule" -Name "clientid" -Value $json.boxAppSettings.clientID -Force
            Set-ItemProperty -Path "HKCU:\Software\boxmodule" -Name "clientsecret" -Value $json.boxAppSettings.clientSecret -Force
            Set-ItemProperty -Path "HKCU:\Software\boxmodule" -Name "passphrase" -Value $json.boxAppSettings.appAuth.passphrase -Force
            Set-ItemProperty -Path "HKCU:\Software\boxmodule" -Name "privatekey" -Value $json.boxAppSettings.appAuth.privateKey -Force
            Set-ItemProperty -Path "HKCU:\Software\boxmodule" -Name "publickeyid" -Value $json.boxAppSettings.appAuth.publicKeyID -Force
        }
        Try
        {
            $boxob = Get-ItemProperty -Path "HKCU:\Software\boxmodule" -ErrorAction Stop
        }
        Catch
        {
            throw "The box authentication values have not been saved. Run this command again and provide the path to the json file with the authentication information."
        }
        If (($boxob.psobject.Properties.name -notcontains "enterpriseid") -or ($boxob.psobject.Properties.name -notcontains "clientid") -or ($boxob.psobject.Properties.name -notcontains "clientSecret") -or ($boxob.psobject.Properties.name -notcontains "passphrase") -or ($boxob.psobject.Properties.name -notcontains "privatekey") -or ($boxob.psobject.Properties.name -notcontains "publickeyid"))
        {
            throw "Box authentication values are missing. Run this command again and provide the path to the json file with the authentication information"
        }
        $boxconfig = New-Object -TypeName Box.v2.Config.Boxconfig -Argumentlist $boxob.clientid, $boxob.clientsecret, $boxob.enterpriseid, $boxob.privatekey, $boxob.passphrase, $boxob.publickeyid
        $boxJWT = New-Object -TypeName Box.V2.JWTAuth.BoxJWTAuth -Argumentlist $boxconfig
        $global:tokenreal = $boxJWT.AdminToken
        If (-not $id)
        {
            $global:adminclient = $boxjwt.AdminClient($tokenreal)
        }
        Else
        {
            $global:adminclient = $boxjwt.AdminClient($tokenreal, $id)
        }
        #return $global:adminclient
    }
    function get-boxusers
    {
        [CmdletBinding(DefaultParameterSetName = "autopage")]
        param
        (
            [Parameter()]
            [string]$SearchString,
            [Parameter(Mandatory = $true, ParameterSetName = "noautopage")]
            [ValidateRange(1, 1000)]
            [int]$limit,
            [Parameter(Mandatory = $true, ParameterSetName = "noautopage")]
            [int]$offset,
            [Parameter()]
            [String[]]$fields,
            [String]$usertype,
            [String]$externalappuserid,
            [Parameter(ParameterSetName = 'autopage')]
            [Switch]$autopaginate
        )
        If ($PSCmdlet.ParameterSetName -like "autopage")
        {
            $usertask = $adminclient.UsersManager.GetEnterpriseUsersAsync($PSBoundParameters.SearchString, 0, 1000, $PSBoundParameters.fields, $PSBoundParameters.usertype, $PSBoundParameters.externalappuserid, $true)
        }
        Else
        {
            $usertask = $adminclient.UsersManager.GetEnterpriseUsersAsync($PSBoundParameters.SearchString, $PSBoundParameters.offset, $PSBoundParameters.limit, $PSBoundParameters.fields, $PSBoundParameters.usertype, $PSBoundParameters.externalappuserid, $false)
        }
        $usertask.Wait()
        If ($usertask.IsFaulted -eq $true)
        {
            return $usertask.Exception.InnerException
        }
        else
        {
            $psob = New-Object -TypeName System.Management.Automation.PSObject
            $psob | Add-Member -MemberType NoteProperty -Name "entries" -Value $usertask.Result.Entries
            $psob | Add-Member -MemberType NoteProperty -Name "TotalCount" -Value $usertask.Result.TotalCount
            return $psob
        }
    }
    function set-boxuserlogin
    {
        param
        (
            [parameter(Mandatory = $true)]
            [System.String]$id,
            [parameter(Mandatory = $true)]
            [string]$newlogin,
            [Parameter()]
            [String[]]$userinfo
        )
        $change = $adminclient.UsersManager.ChangeUsersLoginAsync($id, $newlogin, $PSBoundParameters.userinfo)
        $change.wait()
        If ($change.IsFaulted -eq $true)
        {
            $result = $change.Exception.InnerException
        }
        Else
        {
            $result = $change.Status
        }
        return $result
    }
    function new-boxuser
    {
        param
        (
            [parameter(Mandatory = $true)]
            [hashtable]$userdetails,
            [String[]]$userinfo
        )
        If (($userdetails.Keys -notcontains "name") -and ($userdetails.Keys -notcontains "login"))
        {
            Write-Error "The hashtable does not define the `"name`" or `"login`" keys. These must be present to create the new user."
            return
        }
        Else
        {
            $userrequest = New-Object Box.V2.Models.BoxUserRequest -Property $userdetails
            $newuser = $adminclient.UsersManager.CreateEnterpriseUserAsync($userrequest, $PSBoundParameters.userinfo)
            $newuser.Wait()
            If ($newuser.IsFaulted -eq $true)
            {
                return $newuser.Exception.InnerException
            }
            Else
            {
                return $newuser.Result
            }
        }
    }
    
    function add-boxemailalias
    {
        [CmdletBinding()]
        param (
            [Parameter(Mandatory = $true)]
            [String]$id,
            [Parameter(Mandatory = $true)]
            [String]$emailalias
        )
        $emailaliasproc = $adminclient.UsersManager.AddEmailAliasAsync($id, $emailalias)
        $emailaliasproc.Wait()
        If ($emailaliasproc.IsFaulted -eq $true)
        {
            return $emailaliasproc.Exception.InnerException
        }
        Else
        {
            return $emailaliasproc.Result
        }
    }
    function remove-boxuser
    {
        [CmdletBinding()]
        param (
            [Parameter(Mandatory = $true)]
            [String]$id,
            [Switch]$notify,
            [Switch]$force
        )
        If ($notify)
        {
            If ($force)
            {
                $delete = $adminclient.UsersManager.DeleteEnterpriseUserAsync($id, $true, $true)
            }
            Else
            {
                $delete = $adminclient.UsersManager.DeleteEnterpriseUserAsync($id, $true, $false)
            }
        }
        Else
        {
            If ($force)
            {
                $delete = $adminclient.UsersManager.DeleteEnterpriseUserAsync($id, $false, $true)
            }
            Else
            {
                $delete = $adminclient.UsersManager.DeleteEnterpriseUserAsync($id, $false, $false)
            }
        }
        $delete.Wait()
        If ($delete.IsFaulted -eq $true)
        {
            Return $delete.Exception.InnerException
        }
        Else
        {
            return $delete.Status
        }
        
    }
    
    function transfer-boxusercontent
    {
        [CmdletBinding()]
        param (
            [Parameter(Mandatory = $true)]
            [String]$id,
            [Parameter(Mandatory = $true)]
            [String]$ownerid,
            [Switch]$notify
        )
        If ($notify)
        {
            $transfer = $adminclient.UsersManager.MoveUserFolderAsync($id, $ownerid, "0", $true)
        }
        Else
        {
            $transfer = $adminclient.UsersManager.MoveUserFolderAsync($id, $ownerid, "0", $false)
        }
        $transfer.Wait()
        If ($transfer.IsFaulted -eq $true)
        {
            $transfer.Exception.InnerException
        }
        Else
        {
            $transfer.Result
        }
    }
    
    function upload-boxfile
    {
        [CmdletBinding()]
        param (
            [Parameter(Mandatory = $true)]
            [String]$filename,
            [Parameter(Mandatory = $true)]
            [String]$parentdirid,
            [Parameter(Mandatory = $true)]
            [String]$path,
            [String[]]$fields,
            [Parameter(Mandatory = $true)]
            [system.TimeSpan]$time
        )
        If (!(Test-Path $path))
        {
            Write-Error "The file path you provided does not exist."
            Return
        }
        $file = [System.IO.File]::OpenRead($path)
        $request = @{
            name = "$filename"
            parent = @{
                id = "$parentdirid"
            }
        }
        $upload = $adminclient.FilesManager.UploadAsync($request, $file, $PSBoundParameters.fields, $PSBoundParameters.time)
        $upload.Wait()
        If ($upload.IsFaulted -eq $true)
        {
            return $upload.Exception.InnerException
        }
        Else
        {
            return $upload.Result
        }
    }
    Function remove-boxemailalias
    {
        param (
            [Parameter(Mandatory = $true)]
            [String]$userid,
            [Parameter(Mandatory = $true)]
            [String]$aliasid
        )
        $removealias = $adminclient.UsersManager.DeleteEmailAliasAsync($userid, $aliasid)
        $removealias.Wait()
        If ($removealias.IsFaulted -eq $true)
        {
            return $removealias.Exception.InnerException
        }
        Else
        {
            return $removealias.Result
        }
    }
    function Get-boxemailalias
    {
        param (
            [Parameter(Mandatory = $true)]
            [String]$userid
        )
        $getalias = $adminclient.UsersManager.GetEmailAliasesAsync($userid)
        $getalias.Wait()
        If ($getalias.IsFaulted -eq $true)
        {
            return $getalias.Exception.InnerException
        }
        Else
        {
            return $getalias.Result.Entries
        }
    }
    function Get-boxuserinfo
    {
        param (
            [Parameter(Mandatory = $true)]
            [String]$userid
        )
        $userinfo = $adminclient.UsersManager.GetUserInformationAsync($userid)
        $userinfo.Wait()
        If ($userinfo.IsFaulted -eq $true)
        {
            return $userinfo.Exception.InnerException
        }
        Else
        {
            return $userinfo.Result
        }
    }
    function invite-usertobox
    {
        param (
            [Parameter(Mandatory = $true)]
            [String]$exuseremail,
            [System.String[]]$fields
        )
        Try
        {
            $boxob = Get-ItemProperty -Path "HKCU:\Software\boxmodule" -ErrorAction Stop
        }
        Catch
        {
            throw "Authentication information is missing from the environment. Please run `"connect-box`" to retrieve needed authentication info."
        }
        If (($boxob.psobject.Properties.name -notcontains "enterpriseid") -or ($boxob.psobject.Properties.name -notcontains "clientid") -or ($boxob.psobject.Properties.name -notcontains "clientSecret") -or ($boxob.psobject.Properties.name -notcontains "passphrase") -or ($boxob.psobject.Properties.name -notcontains "privatekey") -or ($boxob.psobject.Properties.name -notcontains "publickeyid"))
        {
            throw "Authentication information is missing from the environment. Please run `"connect-box`" to retrieve needed authentication info."
        }
        $act = New-Object Box.V2.Models.BoxActionableByRequest
        $act.Login = $exuseremail
        $req = New-Object Box.V2.Models.BoxRequestEntity
        $req.Id = (Get-ItemProperty "HKCU:\Software\boxmodule").enterpriseid
        $inviteob = New-Object Box.V2.Models.BoxUserInviteRequest
        $inviteob.ActionableBy = $act
        $inviteob.Enterprise = $req
        If ($PSBoundParameters.Keys -notcontains "fields")
        {
            $invreq = $adminclient.UsersManager.InviteUserToEnterpriseAsync($inviteob)
        }
        Else
        {
            $invreq = $adminclient.UsersManager.InviteUserToEnterpriseAsync($inviteob, $fields)
        }
        $invreq.Wait()
        If ($invreq.IsFaulted -eq $true)
        {
            return $invreq.Exception.InnerException
        }
        Else
        {
            $psob = New-Object -TypeName System.Management.Automation.PSObject
            $psob | Add-Member -MemberType NoteProperty -Name "InvitedUser" -Value $invreq.Result.ActionableBy
            $psob | Add-Member -MemberType NoteProperty -Name "invitedto" -Value $invreq .Result.invitedto
            $psob | Add-Member -MemberType NoteProperty -Name "status" -Value $invreq .Result.status
            $psob | Add-Member -MemberType NoteProperty -Name "id" -Value $invreq .Result.id
            return $psob
        }
        
    }
    
    function Get-boxuserinvite
    {
        param (
            [Parameter(Mandatory = $true)]
            [String]$inviteid,
            [System.String[]]$fields
        )
        If ($PSBoundParameters.Keys -notcontains "fields")
        {
            $invitereq = $adminclient.UsersManager.GetUserInviteAsync($inviteid)
        }
        Else
        {
            $invitereq = $adminclient.UsersManager.GetUserInviteAsync($inviteid, $fields)
        }
        $invitereq.Wait()
        If ($invitereq.IsFaulted -eq $true)
        {
            return $invitereq.Exception.InnerException
        }
        Else
        {
            $psob = New-Object -TypeName System.Management.Automation.PSObject
            $psob | Add-Member -MemberType NoteProperty -Name "InvitedUser" -Value $invitereq.Result.ActionableBy
            $psob | Add-Member -MemberType NoteProperty -Name "invitedto" -Value $invitereq.Result.invitedto
            $psob | Add-Member -MemberType NoteProperty -Name "status" -Value $invitereq.Result.status
            $psob | Add-Member -MemberType NoteProperty -Name "id" -Value $invitereq.Result.id
            return $psob
        }
        
    }
    function set-boxuser
    {
        param (
            [Parameter(Mandatory = $true)]
            [hashtable]$updateinfo,
            [System.String[]]$fields
        )
        $boxuserreq = New-Object Box.V2.Models.BoxUserRequest -Property $updateinfo
        If ($PSBoundParameters.Keys -notcontains "fields")
        {
            $userupdate = $adminclient.UsersManager.UpdateUserInformationAsync($boxuserreq)
        }
        Else
        {
            $userupdate = $adminclient.UsersManager.UpdateUserInformationAsync($boxuserreq, $fields)
        }
        $userupdate.Wait()
        If ($userupdate.IsFaulted -eq $true)
        {
            return $userupdate.Exception.InnerException
        }
        Else
        {
            return $userupdate.Result
        }
    }
    
    function new-boxfolder
    {
        param (
            [Parameter(Mandatory = $true)]
            [hashtable]$foldreq,
            [string[]]$fields
        )
        $folderreq = New-Object Box.V2.Models.BoxFolderRequest -Property $foldreq
        If ($PSBoundParameters.Keys -notcontains "fields")
        {
            $boxfolreq = $adminclient.FoldersManager.CreateAsync($folderreq)
        }
        Else
        {
            $boxfolreq = $adminclient.FoldersManager.CreateAsync($folderreq, $fields)
        }
        $boxfolreq.Wait()
        If ($boxfolreq.IsFaulted -eq $true)
        {
            return $boxfolreq.Exception.InnerException
        }
        Else
        {
            return $yu.Result
        }
        
    }
    function get-boxfolderitems
    {
        [CmdletBinding(DefaultParameterSetName = "auto")]
        param (
            [string]$folderid = "0",
            [Parameter(ParameterSetName = 'noauto')]
            [int]$offset = 0,
            [Parameter(ParameterSetName = 'noauto')]
            [int]$limit = 1000,
            [Parameter(ParameterSetName = 'auto')]
            [Switch]$autopage,
            [System.String[]]$fields
        )
        If ($PSCmdlet.ParameterSetName -like "auto")
        {
            $foldlist = $adminclient.FoldersManager.GetFolderItemsAsync($folderid, 1000, 0, $PSBoundParameters.fields, $true)
        }
        Else
        {
            $foldlist = $adminclient.FoldersManager.GetFolderItemsAsync($folderid, $limit, $offset, $PSBoundParameters.fields, $false)
        }
        $foldlist.Wait()
        If ($foldlist.IsFaulted -eq $true)
        {
            return $foldlist.Exception.InnerException
        }
        Else
        {
            $psob = New-Object -TypeName System.Management.Automation.PSObject
            $psob | Add-Member -MemberType NoteProperty -Name "totalcount" -Value $foldlist.Result.TotalCount
            $psob | Add-Member -MemberType NoteProperty -Name "Entries" -Value $foldlist.Result.Entries
            return $psob
        }
    }
    function new-boxfoldersharelink
    {
        param (
            [Parameter(Mandatory = $true)]
            [String]$foldid,
            [ValidateSet("open", "collaborators", "company")]
            [System.String]$accesstype = "open",
            [System.String[]]$fields
        )
        $sharelink = [Box.V2.Models.BoxSharedLinkRequest]::new()
        $sharelink.Access = $accesstype
        If ($PSBoundParameters.Keys -notcontains "fields")
        {
            $sharelinkreq = $adminclient.FoldersManager.CreateSharedLinkAsync($foldid, $sharelink)
        }
        Else
        {
            $sharelinkreq = $adminclient.FoldersManager.CreateSharedLinkAsync($foldid, $sharelink, $fields)
        }
        $sharelinkreq.Wait()
        If ($sharelinkreq.IsFaulted -eq $true)
        {
            return $sharelinkreq.Exception.InnerException
        }
        Else
        {
            return $sharelinkreq.Result
        }
    }
    function copy-boxfolder
    {
        param (
            [Parameter(Mandatory = $true)]
            [String]$folderid,
            [Parameter(Mandatory = $true)]
            [String]$parentfolderid,
            [System.String[]]$fields
        )
        $folreq = @{
            id = "$folderid"
            parent = @{
                id = "$parentfolderid"
            }
        }
        If ($PSBoundParameters.Keys -notcontains "fields")
        {
            $proc = $adminclient.FoldersManager.CopyAsync($folreq)
        }
        Else
        {
            $proc = $adminclient.FoldersManager.CopyAsync($folreq, $fields)
        }
        $proc.Wait()
        If ($proc.IsFaulted -eq $true)
        {
            return $proc.Exception.InnerException
        }
        Else
        {
            return $proc.Result
        }
    }
    
    function remove-boxfolder
    {
        param (
            [Parameter(Mandatory = $true)]
            [String]$folderid,
            [Switch]$recurse
        )
        If ($recurse)
        {
            $folddelete = $adminclient.FoldersManager.DeleteAsync($folderid, $true)
        }
        Else
        {
            $folddelete = $adminclient.FoldersManager.DeleteAsync($folderid)
        }
        $folddelete.Wait()
        If ($folddelete.IsFaulted -eq $true)
        {
            return $folddelete.Exception.InnerException
        }
        Else
        {
            return $folddelete.Status
        }
    }
    function copy-boxfile
    {
        param (
            [Parameter(Mandatory = $true)]
            [System.String]$fileid,
            [Parameter(Mandatory = $true)]
            [String]$parentfolderid,
            [System.String[]]$fields
        )
        $copyreq = @{
            id = "$fileid"
            parent = @{
                id = "$parentfolderid"
            }
        }
        If ($PSBoundParameters.Keys -notcontains "fields")
        {
            $copyfile = $adminclient.FilesManager.CopyAsync($copyreq)
        }
        Else
        {
            $copyfile = $adminclient.FilesManager.CopyAsync($copyreq, $fields)
        }
        $copyfile.Wait()
        If ($copyfile.IsFaulted -eq $true)
        {
            return $copyfile.Exception.InnerException
        }
        Else
        {
            return $copyfile.Result
        }
    }
    function remove-boxfoldersharedlink
    {
        param (
            [Parameter(Mandatory = $true)]
            [System.String]$sharedlinkid
        )
        $delshare = $adminclient.FoldersManager.DeleteSharedLinkAsync($sharedlinkid)
        $delshare.Wait()
        If ($delshare.IsFaulted -eq $true)
        {
            return $delshare.Exception.InnerException
        }
        Else
        {
            return $delshare.result
        }
    }
    function get-boxfolderinfo
    {
        param (
            [Parameter(Mandatory = $true)]
            [String]$folderid,
            [System.String[]]$fields
        )
        If ($PSBoundParameters.Keys -notcontains "fields")
        {
            $folinfo = $adminclient.FoldersManager.GetInformationAsync($folderid)
        }
        Else
        {
            $folinfo = $adminclient.FoldersManager.GetInformationAsync($folderid, $fields)
        }
        $folinfo.Wait()
        If ($folinfo.IsFaulted -eq $true)
        {
            return $folinfo.Exception.InnerException
        }
        Else
        {
            return $folinfo.Result
        }
        
    }
    function get-boxfoldercollaborations
    {
        param (
            [Parameter(Mandatory = $true)]
            [ValidateNotNullOrEmpty]
            [String]$foldid,
            [System.String[]]$fields
        )
        If ($PSBoundParameters.Keys -notcontains "fields")
        {
            $foldcollab = $adminclient.FoldersManager.GetCollaborationsAsync($foldid)
        }
        Else
        {
            $foldcollab = $adminclient.FoldersManager.GetCollaborationsAsync($foldid, $fields)
        }
        $foldcollab.Wait()
        If ($foldcollab.IsFaulted -eq $true)
        {
            return $foldcollab.Exception.InnerException
        }
        Else
        {
            return $foldcollab.Result
        }
    }
    function Get-boxtrasheditems
    {
        [CmdletBinding(DefaultParameterSetName = "autopage")]
        param (
            [Parameter(ParameterSetName = 'autopage')]
            [switch]$autopage,
            [Parameter(ParameterSetName = "noautopage", Mandatory = $true)]
            [int]$limit,
            [Parameter(ParameterSetName = 'noautopage', Mandatory = $true)]
            [int]$offset,
            [System.String[]]$fields
        )
        If ($PSCmdlet.ParameterSetName -like "autopage")
        {
            $trasheditems = $adminclient.FoldersManager.GetTrashItemsAsync(1000, 0, $PSBoundParameters.fields, $true)
        }
        Else
        {
            $trasheditems = $adminclient.FoldersManager.GetTrashItemsAsync($PSBoundParameters.limit, $PSBoundParameters.offset, $PSBoundParameters.fields, $false)
        }
        $trasheditems.Wait()
        If ($trasheditems.IsFaulted -eq $true)
        {
            return $trasheditems.Exception.InnerException
        }
        Else
        {
            return $trasheditems.Result
        }
    }
    function get-trashedboxfolder
    {
        param (
            [Parameter(Mandatory = $true)]
            [String]$foldid,
            [System.String[]]$fields
        )
        If ($PSBoundParameters.Keys -notcontains "fields")
        {
            $trashfold = $adminclient.FoldersManager.GetTrashedFolderAsync($foldid)
        }
        Else
        {
            $trashfold = $adminclient.FoldersManager.GetTrashedFolderAsync($foldid, $fields)
        }
        $trashfold.Wait()
        If ($trashfold.IsFaulted -eq $true)
        {
            return $trashfold.Exception.InnerException
        }
        Else
        {
            return $trashfold.Result
        }
    }
    function remove-boxtrashfolder
    {
        param (
            [Parameter(Mandatory = $true)]
            [String]$foldid
        )
        $purgefold = $adminclient.FoldersManager.PurgeTrashedFolderAsync($foldid)
        $purgefold.Wait()
        If ($purgefold.IsFaulted -eq $true)
        {
            return $purgefold.Exception.InnerException
        }
        Else
        {
            return $purgefold.Status
        }
    }
    function restore-trashedboxfolder
    {
        param (
            [Parameter(Mandatory = $true)]
            [String]$trashedfolderid,
            [Parameter(Mandatory = $true)]
            [String]$restoretofolderid,
            [System.String[]]$fields
        )
        $foldreq = @{
            id = "$trashedfolderid"
            parent = @{
                id = "$restoretofolderid"
            }
        }
        If ($PSBoundParameters.Keys -notcontains "fields")
        {
            $restorefold = $adminclient.FoldersManager.RestoreTrashedFolderAsync($foldreq)
        }
        Else
        {
            $restorefold = $adminclient.FoldersManager.RestoreTrashedFolderAsync($foldreq, $fields)
        }
        $restorefold.Wait()
        If ($restorefold.IsFaulted -eq $true)
        {
            return $restorefold.Exception.InnerException
        }
        Else
        {
            return $restorefold.Result
        }
    }
    
    function update-boxfolderinfo
    {
        param (
            [Parameter(Mandatory = $true)]
            [Box.V2.Models.BoxFolderRequest]$updateinfo,
            [System.String[]]$fields
        )
        If ($PSBoundParameters.Keys -notcontains "fields")
        {
            $folderupdate = $adminclient.FoldersManager.UpdateInformationAsync($updateinfo)
        }
        Else
        {
            $folderupdate = $adminclient.FoldersManager.UpdateInformationAsync($updateinfo, $fields)
        }
        $folderupdate.Wait()
        If ($folderupdate.IsFaulted -eq $true)
        {
            return $folderupdate.Exception.InnerException
        }
        Else
        {
            return $folderupdate.Result
        }
    }
    function get-boxcollections
    {
        $getcoll = $adminclient.CollectionsManager.GetCollectionsAsync()
        $getcoll.Wait()
        
    }
    Export-ModuleMember -Function connect-box, get-boxusers, set-boxuserlogin, new-boxuser, remove-boxuser, add-boxemailalias, transfer-boxusercontent, upload-boxfile, Get-boxemailalias, Get-boxuserinfo, Get-boxuserinvite, invite-usertobox, remove-boxemailalias, set-boxuser, new-boxfolder, get-boxfolderitems, new-boxfoldersharelink, copy-boxfolder, remove-boxfolder, copy-boxfile, remove-boxfoldersharedlink, get-boxuserinfo, new-boxfoldersharelink, get-boxfolderinfo, get-boxfoldercollaborations, Get-boxtrasheditems, get-trashedboxfolder, remove-boxtrashfolder, restore-trashedboxfolder, update-boxfolderinfo