Kā pārsūtīt OneDrive failus citam lietotājam, izmantojot PowerShell

Ka Parsutit Onedrive Failus Citam Lietotajam Izmantojot Powershell



Failu pārsūtīšana no sava Microsoft OneDrive konta citam lietotājam ir vienkārša tādā nozīmē, ka varat lejupielādēt saturu no sava OneDrive un pēc tam manuāli augšupielādēt tos citā kontā. Šajā rakstā mēs jums parādīsim, kā to izdarīt pārsūtīt OneDrive failus citam lietotājam, izmantojot PowerShell .



  Kā pārsūtīt OneDrive failus citam lietotājam, izmantojot PowerShell





vāciņu bloķēšanas indikatora logi 7

Lietas, kas jāņem vērā

Kad runa ir par failu augšupielādi no sava OneDrive uz citu kontu, tas prasīs kādu laiku, jo pašlaik nav iespējams augšupielādēt failus, kas lielāki par 250 MB. Labā ziņa ir tā, ka PowerShell atzīmēs visus failus, kurus nevar augšupielādēt, lai jūs varētu tos meklēt un kopīgot, izmantojot parasto metodi.





Pirms failu augšupielādes citā OneDrive kontā faili vispirms tiks lejupielādēti jūsu datorā, tāpēc, pirms turpināt darbu, pārliecinieties, ka cietajā diskā vai SSD ir pietiekami daudz vietas. Un tā kā ir nepieciešams interneta savienojums, kopējais pārsūtīšanas ātrums būs atkarīgs no tīkla kvalitātes.



Tagad mums jāņem vērā, ka administratora kontā nepastāv divu faktoru autentifikācija, tāpēc izveidojiet pagaidu administratora kontu, kuram nav 2FA tikai šim nolūkam.

Lietas, kas jums būs vajadzīgas

Mēs izmantosim īpašu skriptu, lai pārvietotu failus no viena OneDrive konta uz citu. Tātad, lai skripts darbotos ar problēmām, lūdzu, tūlīt instalējiet šādus PowerShell moduļus:

SharePoint PnP PowerShell modulis



Atveriet PowerShell rīku kā administrators, pēc tam palaidiet šo komandu:

Install-Module SharePointPnPPowerShellOnline -Force

SharePoint Online pārvaldības apvalks

Šī rīka mērķis ir mainīt lietotāja OneDrive konta atļaujas.

Lejupielādējiet un instalējiet to bez maksas no microsoft.com .

MSOnline V1 Powershell modulis

Lai instalētu šo pēdējo moduli, lūdzu, palaidiet šo komandu programmā PowerShell kā administrators:

Install-Module MSOnline -Force

Kā pārsūtīt OneDrive failus uz citu kontu

Lai pārsūtītu failus no sava OneDrive konta uz citu, jums ir jāatver PowerShell un pēc tam jāpalaiž nodrošinātais skripts.

Atveriet PowerShell

  Microsoft PowerShell meklēšana

Atveriet Visual Studio Code vai PowerShell.

To var izdarīt, noklikšķinot uz pogas Meklēt un pēc tam meklējot PowerShell.

Pēc tam ar peles labo pogu noklikšķiniet uz lietotnes un pēc tam atlasiet opciju, kas paredzēta, lai atvērtu rīku administratora režīmā.

Palaidiet skriptu

  OneDrive PowerShell skripts

Pēc tam jums ir jāpalaiž attiecīgais skripts. To var atrast raksta apakšā.

Mēs izvēlējāmies to darīt, jo skripts ir diezgan garš.

veikt tālruņa zvanus no Windows 10

Pēc skripta pievienošanas nospiediet tastatūras taustiņu Enter.

Pārsūtiet failus

Visbeidzot, ir pienācis laiks pārsūtīt failus uz citu OneDrive kontu.

Redzi, tūlīt pēc Enter taustiņa nospiešanas jums tiks lūgts pievienot e-pasta kontu Aizejošā lietotāja lietotājvārds .

Jums arī vajadzēs Mērķa lietotāja lietotājvārds . Šis ir OneDrive lietotājs, uz kuru faili tiks kopēti un pārsūtīti.

Visbeidzot, jums tiks lūgts pievienot Jūsu Office 365 administratora lietotājvārds .

Pagaidiet, līdz skripts paveiks savu uzdevumu, pirms pārbaudāt saņēmēja kontu, lai redzētu, vai faili ir pārsūtīti pareizi.

Kopējiet un ielīmējiet tālāk norādīto skriptu:

$departinguser = Read-Host "Enter departing user's email"
$destinationuser = Read-Host "Enter destination user's email"
$globaladmin = Read-Host "Enter the username of your Global Admin account"
$credentials = Get-Credential -Credential $globaladmin
Connect-MsolService -Credential $credentials
$InitialDomain = Get-MsolDomain | Where-Object {$_.IsInitial -eq $true}
  
$SharePointAdminURL = "https://$($InitialDomain.Name.Split(".")[0])-admin.sharepoint.com"
  
$departingUserUnderscore = $departinguser -replace "[^a-zA-Z]", "_"
$destinationUserUnderscore = $destinationuser -replace "[^a-zA-Z]", "_"
  
$departingOneDriveSite = "https://$($InitialDomain.Name.Split(".")[0])-my.sharepoint.com/personal/$departingUserUnderscore"
$destinationOneDriveSite = "https://$($InitialDomain.Name.Split(".")[0])-my.sharepoint.com/personal/$destinationUserUnderscore"
Write-Host "`nConnecting to SharePoint Online" -ForegroundColor Blue
Connect-SPOService -Url $SharePointAdminURL -Credential $credentials
  
Write-Host "`nAdding $globaladmin as site collection admin on both OneDrive site collections" -ForegroundColor Blue
# Set current admin as a Site Collection Admin on both OneDrive Site Collections
Set-SPOUser -Site $departingOneDriveSite -LoginName $globaladmin -IsSiteCollectionAdmin $true
Set-SPOUser -Site $destinationOneDriveSite -LoginName $globaladmin -IsSiteCollectionAdmin $true
Write-Host "`nConnecting to $departinguser's OneDrive via SharePoint Online PNP module" -ForegroundColor Blue
Connect-PnPOnline -Url $departingOneDriveSite -Credentials $credentials
Write-Host "`nGetting display name of $departinguser" -ForegroundColor Blue
# Get name of departing user to create folder name.
$departingOwner = Get-PnPSiteCollectionAdmin | Where-Object {$_.loginname -match $departinguser}
# If there's an issue retrieving the departing user's display name, set this one.
 if  ($departingOwner -contains $null) {
    $departingOwner = @{
        Title = "Departing User"
    }
}
  
# Define relative folder locations for OneDrive source and destination
$departingOneDrivePath = "/personal/$departingUserUnderscore/Documents"
$destinationOneDrivePath = "/personal/$destinationUserUnderscore/Documents/$($departingOwner.Title)'s Files"
$destinationOneDriveSiteRelativePath = "Documents/$($departingOwner.Title)'s Files"
  
Write-Host "`nGetting all items from $($departingOwner.Title)" -ForegroundColor Blue
# Get all items from source OneDrive
$items = Get-PnPListItem -List Documents -PageSize 1000
$largeItems = $items | Where-Object {[long]$_.fieldvalues.SMTotalFileStreamSize -ge 261095424 -and $_.FileSystemObjectType -contains "File"}
 if  ($largeItems) {
    $largeexport = @()
     foreach  ($item  in  $largeitems) {
        $largeexport += "$(Get-Date) - Size: $([math]::Round(($item.FieldValues.SMTotalFileStreamSize / 1MB),2)) MB Path: $($item.FieldValues.FileRef)"
        Write-Host "File too large to copy: $($item.FieldValues.FileRef)" -ForegroundColor DarkYellow
    }
    $largeexport | Out-file C:\temp\largefiles.txt -Append
    Write-Host "A list of files too large to be copied from $($departingOwner.Title) have been exported to C:\temp\LargeFiles.txt" -ForegroundColor Yellow
}
$rightSizeItems = $items | Where-Object {[long]$_.fieldvalues.SMTotalFileStreamSize -lt 261095424 -or $_.FileSystemObjectType -contains "Folder"}
Write-Host "`nConnecting to $destinationuser via SharePoint PNP PowerShell module" -ForegroundColor Blue
Connect-PnPOnline -Url $destinationOneDriveSite -Credentials $credentials
Write-Host "`nFilter by folders" -ForegroundColor Blue
# Filter by Folders to create directory structure
$folders = $rightSizeItems | Where-Object {$_.FileSystemObjectType -contains "Folder"}
  
Write-Host "`nCreating Directory Structure" -ForegroundColor Blue
 foreach  ($folder  in  $folders) {
    $path = ('{0}{1}' -f $destinationOneDriveSiteRelativePath, $folder.fieldvalues.FileRef).Replace($departingOneDrivePath, '')
    Write-Host "Creating folder in $path" -ForegroundColor Green
    $newfolder = Ensure-PnPFolder -SiteRelativePath $path
}
  
Write-Host "`nCopying Files" -ForegroundColor Blue
$files = $rightSizeItems | Where-Object {$_.FileSystemObjectType -contains "File"}
$fileerrors = ""
foreach ($file in $files) {
    $destpath = ("$destinationOneDrivePath$($file.fieldvalues.FileDirRef)").Replace($departingOneDrivePath, "")
    Write-Host "Copying $($file.fieldvalues.FileLeafRef) to $destpath" -ForegroundColor Green
    $newfile = Copy-PnPFile -SourceUrl $file.fieldvalues.FileRef -TargetUrl $destpath -OverwriteIfAlreadyExists -Force -ErrorVariable errors -ErrorAction SilentlyContinue
    $fileerrors += $errors
}
$fileerrors | Out-File c:\temp\fileerrors.txt
# Remove Global Admin from Site Collection Admin role for both users
Write-Host "`nRemoving $globaladmin from OneDrive site collections" -ForegroundColor Blue
Set-SPOUser -Site $departingOneDriveSite -LoginName $globaladmin -IsSiteCollectionAdmin $false
Set-SPOUser -Site $destinationOneDriveSite -LoginName $globaladmin -IsSiteCollectionAdmin $false
Write-Host "`nComplete!" -ForegroundColor Green

Šeit varat atrast skriptu Reddit lapa .

LASĪT : Kā eksportēt CSV programmā PowerShell operētājsistēmā Windows

Vai PowerShell var piekļūt OneDrive?

SharePoint Online PowerShell ļaus lietotājiem izveidot savienojumu ar citu OneDrive kontu, izmantojot PowerShell rīku. Tas lūgs ievadīt paroli, lai PowerShell varētu sākt strādāt ar jūsu OneDrive kontiem, izmantojot cmdlet.

Vai OneDrive var piekļūt ārējie lietotāji?

Jūsu OneDrive kontam var piekļūt ārējie lietotāji, taču tikai tad, ja jūs to atļaujat. Lietotāji var piekļūt jūsu failiem uz visiem laikiem vai uz noteiktu laika periodu. Varat arī ierobežot to, ko viņi var darīt.

Kā kopēt failus no citas personas OneDrive?

Ja vēlaties kopēt failus no citas personas OneDrive, jums ir šādas iespējas:

  • Atveriet OneDrive savā pārlūkprogrammā, izmantojot saiti, atlasiet failus, kurus vēlaties kopēt, un noklikšķiniet uz Lejupielādēt. Tas tiks lejupielādēts jūsu datorā.
  • Atveriet OneDrive kontu, izmantojot saiti, atlasiet failus, kurus vēlaties kopēt, un noklikšķiniet uz Kopēt uz.

Tieši tā!

  Kā pārsūtīt OneDrive failus citam lietotājam, izmantojot PowerShell
Populārākas Posts