Slackbot
07/16/2020, 9:34 PMJoel - ControlUp
07/17/2020, 12:46 AMLakatta
07/17/2020, 12:48 AMJoel - ControlUp
07/17/2020, 12:57 AMLakatta
07/17/2020, 1:00 AMMike Streetz (O_P)
07/17/2020, 3:24 PMMike Streetz (O_P)
07/17/2020, 3:25 PMMike Streetz (O_P)
07/17/2020, 3:25 PMMike Streetz (O_P)
07/17/2020, 3:26 PMMike Streetz (O_P)
07/17/2020, 3:28 PMLakatta
07/17/2020, 3:29 PMLakatta
07/17/2020, 3:30 PMMike Streetz (O_P)
07/17/2020, 4:00 PMMike Streetz (O_P)
07/17/2020, 4:00 PMLakatta
07/17/2020, 4:01 PMMike Streetz (O_P)
07/17/2020, 4:03 PMStart-Sleep -Seconds 100
#region Functions
function Sync-SharepointLocation {
param (
[guid]$siteId,
[guid]$webId,
[guid]$listId,
[mailaddress]$userEmail,
[string]$webUrl,
[string]$webTitle,
[string]$listTitle,
[string]$syncPath
)
try {
Add-Type -AssemblyName System.Web
#Encode site, web, list, url & email
[string]$siteId = [System.Web.HttpUtility]::UrlEncode($siteId)
[string]$webId = [System.Web.HttpUtility]::UrlEncode($webId)
[string]$listId = [System.Web.HttpUtility]::UrlEncode($listId)
[string]$userEmail = [System.Web.HttpUtility]::UrlEncode($userEmail)
[string]$webUrl = [System.Web.HttpUtility]::UrlEncode($webUrl)
#build the URI
$uri = New-Object System.UriBuilder
$uri.Scheme = "odopen"
$uri.Host = "sync"
$uri.Query = "siteId=$siteId&webId=$webId&listId=$listId&userEmail=$userEmail&webUrl=$webUrl&listTitle=$listTitle&webTitle=$webTitle"
#&folderName=$folderName
#launch the process from URI
Write-Host $uri.ToString()
start-process -filepath $($uri.ToString())
}
catch {
$errorMsg = $_.Exception.Message
}
if ($errorMsg) {
Write-Warning "Sync failed."
Write-Warning $errorMsg
}
else {
Write-Host "Sync completed."
while (!(Get-ChildItem -Path $syncPath -ErrorAction SilentlyContinue)) {
Start-Sleep -Seconds 2
}
return $true
}
}
#endregion
#region Main Process
try {
#region Sharepoint Sync
[mailaddress]$userUpn = cmd /c "whoami/upn"
$params = @{
#replace with data captured from your sharepoint site.
siteId = "{}"
webId = "{}"
listId = "{}"
userEmail = $userUpn
webUrl = "https://yourcompany.sharepoint.com/sites/yourdepartment"
webTitle = "yourcompany"
listTitle = "Documents"
}
$params.syncPath = "$(split-path $env:onedrive)\$("yourcompany")\$($params.webTitle) - $($params.listTitle)"
Write-Host "SharePoint params:"
$params | Format-Table
if (!(Test-Path $($params.syncPath))) {
Write-Host "Sharepoint folder not found locally, will now sync.." -ForegroundColor Yellow
$sp = Sync-SharepointLocation @params
if (!($sp)) {
Throw "Sharepoint sync failed."
}
}
else {
Write-Host "Location already syncronized: $($params.syncPath)" -ForegroundColor Yellow
}
#endregion
}
catch {
$errorMsg = $_.Exception.Message
}
finally {
if ($errorMsg) {
Write-Warning $errorMsg
Throw $errorMsg
}
else {
Write-Host "Completed successfully.."
}
}
#endregionLakatta
07/17/2020, 4:03 PMMike Streetz (O_P)
07/17/2020, 4:04 PMMike Streetz (O_P)
07/17/2020, 4:04 PMMike Streetz (O_P)
07/17/2020, 4:04 PMMike Streetz (O_P)
07/17/2020, 4:04 PMMike Streetz (O_P)
07/17/2020, 4:04 PMMike Streetz (O_P)
07/17/2020, 4:05 PMLakatta
07/17/2020, 4:05 PMMike Streetz (O_P)
07/17/2020, 4:06 PM