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>]
[-DisAllowTrailingDot]
[-PassThru]
[-AsJob]
[-ServerTimeoutPerRequest <Int32>]
[-ClientTimeoutPerRequest <Int32>]
[-DefaultProfile <IAzureContextContainer>]
[-ConcurrentTaskCount <Int32>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Close-AzStorageFileHandle
[-ShareName] <String>
-FileHandle <PSFileHandle>
[-Context <IStorageContext>]
[-DisAllowTrailingDot]
[-PassThru]
[-AsJob]
[-ServerTimeoutPerRequest <Int32>]
[-ClientTimeoutPerRequest <Int32>]
[-DefaultProfile <IAzureContextContainer>]
[-ConcurrentTaskCount <Int32>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Close-AzStorageFileHandle
[-Share] <CloudFileShare>
[-ShareClient <ShareClient>]
[[-Path] <String>]
[-Recursive]
[-CloseAll]
[-PassThru]
[-AsJob]
[-ServerTimeoutPerRequest <Int32>]
[-ClientTimeoutPerRequest <Int32>]
[-DefaultProfile <IAzureContextContainer>]
[-ConcurrentTaskCount <Int32>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Close-AzStorageFileHandle
[-Share] <CloudFileShare>
[-ShareClient <ShareClient>]
-FileHandle <PSFileHandle>
[-PassThru]
[-AsJob]
[-ServerTimeoutPerRequest <Int32>]
[-ClientTimeoutPerRequest <Int32>]
[-DefaultProfile <IAzureContextContainer>]
[-ConcurrentTaskCount <Int32>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Close-AzStorageFileHandle
[-Directory] <CloudFileDirectory>
[-ShareDirectoryClient <ShareDirectoryClient>]
[[-Path] <String>]
[-Recursive]
[-CloseAll]
[-PassThru]
[-AsJob]
[-ServerTimeoutPerRequest <Int32>]
[-ClientTimeoutPerRequest <Int32>]
[-DefaultProfile <IAzureContextContainer>]
[-ConcurrentTaskCount <Int32>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Close-AzStorageFileHandle
[-File] <CloudFile>
[-ShareFileClient <ShareFileClient>]
[-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: Close all file handles on a file
Close-AzStorageFileHandle -ShareName "mysharename" -Path 'dir1/dir2/test.txt' -CloseAll
This command closes all file handles on a file.
Example 2: Close all file handles which is opened 1 day ago on a file directory
Get-AzStorageFileHandle -ShareName "mysharename" -Path 'dir1/dir2' -Recursive | Where-Object {$_.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 closes them.
Example 3: Close all file handles on a file directory recursively and show the closed file handle count
Close-AzStorageFileHandle -ShareName "mysharename" -Path 'dir1/dir2' -Recursive -CloseAll -PassThru
10
This command closes all file handles on a file directory and shows the closed file handle count.
Example 4: Close all file handles on a file share
Close-AzStorageFileHandle -ShareName "mysharename" -CloseAll -Recursive
This command closes all file handles on a specific file share recursively.
Parameters
-AsJob
Run cmdlet in the background
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ClientTimeoutPerRequest
The client side maximum execution time for each request in seconds.
Type: | Nullable<T>[Int32] |
Aliases: | ClientTimeoutPerRequestInSeconds |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-CloseAll
Force close all File handles.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ConcurrentTaskCount
The total amount of concurrent async tasks. The default value is 10.
Type: | Nullable<T>[Int32] |
Position: | Named |
Default value: | None |
Required: | False |
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 |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Context
Azure Storage Context Object
Type: | IStorageContext |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.
Type: | IAzureContextContainer |
Aliases: | AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Directory
CloudFileDirectory object indicated the base folder where the files/directories would be listed.
Type: | CloudFileDirectory |
Aliases: | CloudFileDirectory |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-DisAllowTrailingDot
Disallow trailing dot (.) to suffix directory and file names.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-File
CloudFile object indicated the file to close handle.
Type: | CloudFile |
Aliases: | CloudFile |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-FileHandle
The File Handle to close.
Type: | PSFileHandle |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-PassThru
Return the count of closed file handles.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Path
Path to an existing file/directory.
Type: | String |
Position: | 1 |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Recursive
List handles Recursively. Only works on File Directory.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ServerTimeoutPerRequest
The server time out for each request in seconds.
Type: | Nullable<T>[Int32] |
Aliases: | ServerTimeoutPerRequestInSeconds |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Share
CloudFileShare object indicated the share where the files/directories would be listed.
Type: | CloudFileShare |
Aliases: | CloudFileShare |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ShareClient
ShareClient object indicated the share which contains the files/directories to closed handle.
Type: | ShareClient |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ShareDirectoryClient
ShareDirectoryClient object indicated the base folder which contains the files/directories to closed handle.
Type: | ShareDirectoryClient |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ShareFileClient
ShareFileClient object indicated the file to close handle.
Type: | ShareFileClient |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ShareName
Name of the file share where the files/directories would be listed.
Type: | String |
Position: | 0 |
Default value: | None |
Required: | True |
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 |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |