Module Name | schema | applicable | online version | external help file | title |
---|---|---|---|---|---|
PnP.PowerShell |
2.0.0 |
SharePoint Online |
PnP.PowerShell.dll-Help.xml |
Get-PnPFile |
Downloads a file
Get-PnPFile -Url <String> -AsFileObject [-Connection <PnPConnection>]
Get-PnPFile -Url <String> -AsListItem [-ThrowExceptionIfFileNotFound] [-Connection <PnPConnection>]
Get-PnPFile -Url <String> -AsFile -Path <String> -Filename <String> [-Force] [-Connection <PnPConnection>]
Get-PnPFile -Url <String> -AsString [-Connection <PnPConnection>]
Get-PnPFile -Url <String> -AsMemoryStream [-Connection <PnPConnection>]
Allows downloading of a file from SharePoint Online. The file contents can either be read directly into memory as text, directly saved to local disk or stored in memory for further processing.
Get-PnPFile -Url "/sites/project/Shared Documents/Document.docx"
Retrieves the file and downloads it to the current folder
Get-PnPFile -Url /sites/project/SiteAssets/image.jpg -Path c:\temp -FileName image.jpg -AsFile
Retrieves the file and downloads it to c:\temp\image.jpg
Get-PnPFile -Url /sites/project/_catalogs/themes/15/company.spcolor -AsString
Retrieves the contents of the file as text and outputs its contents to the console
Get-PnPFile -Url /sites/project/Shared Documents/Folder/Presentation.pptx -AsFileObject
Retrieves the file and returns it as a File object
Get-PnPFile -Url /sites/project/_catalogs/themes/15/company.spcolor -AsListItem
Retrieves the file and returns it as a ListItem object
Get-PnPFile -Url /personal/john_tenant_onmicrosoft_com/Documents/Sample.xlsx -Path c:\temp -FileName Project.xlsx -AsFile
Retrieves the file Sample.xlsx by its site relative URL from a OneDrive for Business site and downloads it to c:\temp\Project.xlsx
Get-PnPFile -Url "/sites/templates/Shared Documents/HR Site.pnp" -AsMemoryStream
Retrieves the file in memory for further processing
Type: SwitchParameter
Parameter Sets: Save to local path
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Retrieve the file contents as a file object.
Type: SwitchParameter
Parameter Sets: Return as file object
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Returns the file as a listitem showing all its properties
Type: SwitchParameter
Parameter Sets: Return as list item
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Retrieve the file contents as a string
Type: SwitchParameter
Parameter Sets: Return as string
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Type: SwitchParameter
Parameter Sets: Download the content of the file to memory
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.
Type: PnPConnection
Parameter Sets: (All)
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Name for the local file
Type: String
Parameter Sets: Save to local path
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Overwrites the file if it exists.
Type: SwitchParameter
Parameter Sets: Save to local path
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Local path where the file should be saved
Type: String
Parameter Sets: Save to local path
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
If provided in combination with -AsListItem, a System.ArgumentException will be thrown if the file specified in the -Url argument does not exist. Otherwise it will return nothing instead.
Type: SwitchParameter
Parameter Sets: Return as list item
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The URL (server or site relative) to the file
Type: String
Parameter Sets: (All)
Aliases: ServerRelativeUrl, SiteRelativeUrl
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False