Close-AzStorageFileHandle

Closes file handles of a file share, a file directory or a file.

Syntax

Close-AzStorageFileHandle
     [-ShareName] <String>
     [[-Path] <String>]
     [-Recursive]
     [-CloseAll]
     [-Context <IStorageContext>]
     [-PassThru]
     [-AsJob]
     [-ServerTimeoutPerRequest <Int32>]
     [-ClientTimeoutPerRequest <Int32>]
     [-DefaultProfile <IAzureContextContainer>]
     [-ConcurrentTaskCount <Int32>]
     [-WhatIf]
     [-Confirm]
     [<CommonParameters>]
Close-AzStorageFileHandle
     [-ShareName] <String>
     -FileHandle <PSFileHandle>
     [-Context <IStorageContext>]
     [-PassThru]
     [-AsJob]
     [-ServerTimeoutPerRequest <Int32>]
     [-ClientTimeoutPerRequest <Int32>]
     [-DefaultProfile <IAzureContextContainer>]
     [-ConcurrentTaskCount <Int32>]
     [-WhatIf]
     [-Confirm]
     [<CommonParameters>]
Close-AzStorageFileHandle
     [-Share] <CloudFileShare>
     [[-Path] <String>]
     [-Recursive]
     [-CloseAll]
     [-PassThru]
     [-AsJob]
     [-ServerTimeoutPerRequest <Int32>]
     [-ClientTimeoutPerRequest <Int32>]
     [-DefaultProfile <IAzureContextContainer>]
     [-ConcurrentTaskCount <Int32>]
     [-WhatIf]
     [-Confirm]
     [<CommonParameters>]
Close-AzStorageFileHandle
     [-Share] <CloudFileShare>
     -FileHandle <PSFileHandle>
     [-PassThru]
     [-AsJob]
     [-ServerTimeoutPerRequest <Int32>]
     [-ClientTimeoutPerRequest <Int32>]
     [-DefaultProfile <IAzureContextContainer>]
     [-ConcurrentTaskCount <Int32>]
     [-WhatIf]
     [-Confirm]
     [<CommonParameters>]
Close-AzStorageFileHandle
     [-Directory] <CloudFileDirectory>
     [[-Path] <String>]
     [-Recursive]
     [-CloseAll]
     [-PassThru]
     [-AsJob]
     [-ServerTimeoutPerRequest <Int32>]
     [-ClientTimeoutPerRequest <Int32>]
     [-DefaultProfile <IAzureContextContainer>]
     [-ConcurrentTaskCount <Int32>]
     [-WhatIf]
     [-Confirm]
     [<CommonParameters>]
Close-AzStorageFileHandle
     [-File] <CloudFile>
     [-CloseAll]
     [-PassThru]
     [-AsJob]
     [-ServerTimeoutPerRequest <Int32>]
     [-ClientTimeoutPerRequest <Int32>]
     [-DefaultProfile <IAzureContextContainer>]
     [-ConcurrentTaskCount <Int32>]
     [-WhatIf]
     [-Confirm]
     [<CommonParameters>]

Description

The Close-AzStorageFileHandle cmdlet closes file handles of a file share, or file directory or a file.

Examples

Example 1: Lists all file shares of current Storage Account, and close all file handles of the file shares recursively.

PS C:\>Get-AzStorageShare | Close-AzStorageFileHandle -CloseAll -Recursive

This command lists all file shares of current Storage Account, and close all file handles of the file shares recursively..

Example 2: Close all file handles on a file directory recursively and show the closed file handle count

PS C:\>Close-AzStorageFileHandle -ShareName "mysharename" -Path 'dir1/dir2' -Recursive -CloseAll -PassThru
10

This command closes all file handles on a file directory and show the closed file handle count.

Example 3: Close all file handles which is opened 1 day ago on a file directory

PS C:\>Get-AzStorageFileHandle -ShareName "mysharename" -Path 'dir1/dir2' -Recursive | ? {$_.OpenTime.DateTime.AddDays(1) -lt (Get-Date)} | Close-AzStorageFileHandle -ShareName "mysharename"

This command lists all file handles on a file directory recursively, filters out the handles which are opened 1 day ago, and then close them.

Example 4: Close all file handles on a file

PS C:\>Close-AzStorageFileHandle -ShareName "mysharename" -Path 'dir1/dir2/test.txt' -CloseAll

This command closes all file handles on a file.

Parameters

-AsJob

Run cmdlet in the background

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ClientTimeoutPerRequest

The client side maximum execution time for each request in seconds.

Type:System.Nullable`1[System.Int32]
Aliases:ClientTimeoutPerRequestInSeconds
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-CloseAll

Force close all File handles.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ConcurrentTaskCount

The total amount of concurrent async tasks. The default value is 10.

Type:System.Nullable`1[System.Int32]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Context

Azure Storage Context Object

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.IStorageContext
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName, ByValue)
Accept wildcard characters:False
-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Directory

CloudFileDirectory object indicated the base folder where the files/directories would be listed.

Type:CloudFileDirectory
Position:0
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-File

CloudFile object indicated the file to close handle.

Type:CloudFile
Position:0
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-FileHandle

The File Handle to close.

Type:Microsoft.WindowsAzure.Commands.Storage.Model.ResourceModel.PSFileHandle
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-PassThru

Return the count of closed file handles.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Path

Path to an existing file/directory.

Type:String
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Recursive

List handles Recursively. Only works on File Directory.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ServerTimeoutPerRequest

The server time out for each request in seconds.

Type:System.Nullable`1[System.Int32]
Aliases:ServerTimeoutPerRequestInSeconds
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Share

CloudFileShare object indicated the share where the files/directories would be listed.

Type:CloudFileShare
Position:0
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-ShareName

Name of the file share where the files/directories would be listed.

Type:String
Position:0
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

CloudFileShare

CloudFileDirectory

Microsoft.Azure.Commands.Common.Authentication.Abstractions.IStorageContext

Outputs

CloseFileHandleResultSegment