Use Object
apobekiaris edited this page Sep 4, 2020
·
6 revisions
external help file: XpandPwsh-help.xml Module Name: XpandPwsh schema: 2.0.0
Use-Object
SYNOPSIS
Disposes a disposable object, same as c# using keyword.
SYNTAX
Use-Object [[-InputObject] <Object>] [-ScriptBlock] <ScriptBlock> [<CommonParameters>]
DESCRIPTION
Disposes a disposable object, same as c# using keyword.
EXAMPLES
Example 1
PS C:\> Use-Object($c=[System.Net.WebClient]::new()){
$c.DownloadFile($_.resource.downloadUrl,$zip)
}
Use a webclient and dispose it when done.
PARAMETERS
-InputObject
{{ Fill InputObject Description }}
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-ScriptBlock
{{ Fill ScriptBlock Description }}
Type: ScriptBlock
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.