Skip to content

Folders and Files

Takashi Shinohara edited this page Aug 31, 2021 · 1 revision

Create a folder

Use the Add-KshFolder cmdlet to create a folder.

$parentFolder = Get-KshFolder -FolderUrl '/sites/japan/hr/Shared%20Documents'
Add-KshFolder -Folder $parentFolder -FolderName 'Estimates'

Approve or reject a folder

The default approval status is Pending. You can use the Set-KshApprovalStatus cmdlet with the -Approve parameter to approve a folder. The -Comment parameter is optional. The approval status will be set to Approved.

$folder = Get-KshFolder -FolderUrl '/sites/japan/hr/Shared%20Documents/Estimates'
Set-KshApprovalStatus -Folder $folder -Approve -Comment 'Approved'

You can use the -Reject parameter to reject a folder. The -Comment parameter is optional. The approval status will be set to Rejected.

$folder = Get-KshFolder -FolderUrl '/sites/japan/hr/Shared%20Documents/Estimates'
Set-KshApprovalStatus -Folder $folder -Reject -Comment 'Rejected'

To change the approval status to Pending, you can use the -Pending parameter.

$folder = Get-KshFolder -FolderUrl '/sites/japan/hr/Shared%20Documents/Estimates'
Set-KshApprovalStatus -Folder $folder -Pending

Upload a file

There are two ways to upload a file using the cmdlets Add-KshFile and Save-KshFile.

The differences are:

  • The Add-KshFile cmdlet uses the FileCreationInformation class. The maximum file size that can be uploaded is 2 MB.
  • The Save-KshFile cmdlet uses the StartUpload, ContinueUpload, and FinishUpload methods of the File class. There are no file size limits.

For more details, see the documentation.

$folder = Get-KshFolder -FolderUrl '/sites/japan/hr/Shared%20Documents'
$uploadStream = [System.IO.File]::OpenRead('./README.txt')
Save-KshFile -Folder $folder -Content $uploadStream -FileName 'README.txt'

Download a file

You can use the Open-KshFile cmdlet to download a file.

$file = Get-KshFile -FileUrl '/sites/japan/hr/Shared%20Documents/README.txt'
$fileStream = Open-KshFile -Identity $file
$downloadStream = [System.IO.File]::OpenWrite('./README.txt')
$fileStream.CopyTo($downloadStream)
$downloadStream.Close()

Check out and check in a file

You can use the Set-KshCheckOutStatus cmdlet with the -CheckOut parameter to check out a file. If a file is checked out, another user cannot edit it.

$file = Get-KshFile -FileUrl '/sites/japan/hr/Shared%20Documents/README.txt'
Set-KshCheckOutStatus -File $file -CheckOut

To check in a file, use the -CheckIn parameter. The -Comment and -CheckInType parameters are optional.

$file = Get-KshFile -FileUrl '/sites/japan/hr/Shared%20Documents/README.txt'
Set-KshCheckOutStatus -File $file -CheckIn -Comment 'Updated README' -CheckInType MajorCheckIn

If you want to discard the check-out state, use the -UndoCheckOut parameter.

$file = Get-KshFile -FileUrl '/sites/japan/hr/Shared%20Documents/README.txt'
Set-KshCheckOutStatus -File $file -UndoCheckOut

Clone this wiki locally