Skip to content

Latest commit

 

History

History
111 lines (75 loc) · 3.46 KB

File metadata and controls

111 lines (75 loc) · 3.46 KB
external help file Microsoft.Online.SharePoint.PowerShell.dll-Help.xml
Module Name Microsoft.Online.SharePoint.PowerShell
online version https://learn.microsoft.com/powershell/module/microsoft.online.sharepoint.powershell/get-spomalwarefilecontent
applicable SharePoint Online
title Get-SPOMalwareFileContent
schema 2.0.0
author vinandi
ms.author vinandi
ms.reviewer

Get-SPOMalwareFileContent

SYNOPSIS

Gets the file stream associated with the malware-infected file stored in SharePoint.

SYNTAX

Get-SPOMalwareFileContent [-MalwareInfectedFile] <SPOMalwareFile> [<CommonParameters>]

DESCRIPTION

The Get-SPOMalwareFileContent cmdlet runs on a single file. If the file is malware-infected then it returns the file stream associated with it. You must be a SharePoint Online administrator to run the Get-SPOMalwareFileContent cmdlet. Note that this cmdlet does not work on files that are not malware-infected.

For permissions and the most current information about Windows PowerShell for SharePoint Online, see the online documentation at Intro to SharePoint Online Management Shell.

EXAMPLES

EXAMPLE 1

$file = Get-SPOMalwareFile -FileUri "https://contoso.com/sites/Marketing/Shared Documents/Doc1.docx"
Get-SPOMalwareFileContent -MalwareInfectedFile $file

Example 1 returns the file stream.

EXAMPLE 2

Get-SPOMalwareFile -FileUri "https://contoso.com/sites/Marketing/Shared Documents/Doc1.docx" | Get-SPOMalwareFileContent

Example 2 returns the file stream.

EXAMPLE 3

$SPOFileUri = "https://contoso.com/sites/Marketing/Shared Documents/Doc1.docx"

$fileName = $SPOFileUri.split("/")[-1]
$localFolder = ".\$fileName"
$targetfile = New-Object IO.FileStream ($localFolder,[IO.FileMode]::Create)
[byte[]]$readbuffer = New-Object byte[] 1024

$file = Get-SPOMalwareFile -FileUri $SPOFileUri
$responseStream = Get-SPOMalwareFileContent -MalwareInfectedFile $file
do{
    $readlength = $responsestream.Read($readbuffer,0,1024)
    $targetfile.Write($readbuffer,0,$readlength)
}
while ($readlength -ne 0)
$targetfile.close()

Example 3 downloads the file to the current working directory using the original filename.

PARAMETERS

-MalwareInfectedFile

Applicable: SharePoint Online

SPOMalwareFile object returned by Get-SPOMalwareFile cmdlet.

Type: Microsoft.Online.SharePoint.TenantAdministration.SPOMalwareFile
Parameter Sets: (All)
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
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.

INPUTS

Microsoft.Online.SharePoint.TenantAdministration.SPOMalwareFile

OUTPUTS

System.Object

NOTES

To get the SPOMalwareFile object, the user should execute the Get-SPOMalwareFile cmdlet first. Then that object can be used as a parameter to the Get-SPOMalwareFileContentContent cmdlet.

RELATED LINKS

Get-SPOMalwareFile

Getting started with SharePoint Online Management Shell