Skip to content

Instantly share code, notes, and snippets.

@win2000b
win2000b / RegExample.reg
Created August 22, 2019 08:10
Registry Example of OneDrive Automount
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\OneDrive\TenantAutoMount]
"Company"="Company#xF000;tenantId=xxxxxxxxxx%2xxxxxxxxxx%2xxxxxxxxxx%2Db6cc%2D95f78012db44&siteId=%xxxxxxxxxx%2Df953%2D41d3%2Da85d%2De1e1e2b12e0a%7D&webId=%7B9e138f17%2D50a9%2xxxxxxxxxxD9ccf%2D330e7a888dea%7D&listId=%7B985E592D%2DAD08%2xxxxxxxxxx%2DF8212867DBE5%7D&webUrl=https%3A%2F%2Fsite%2Esharepoint%2Ecom%2Fsites%2FTechnical&version=1"
@win2000b
win2000b / GetPowerBIDataSetInfo.ps1
Last active July 23, 2022 20:15
PowerBI Collects all server info for workspaces and datasets
# Install PowerBI PowerShell if needed.
Install-Module -Name MicrosoftPowerBIMgmt
# Connect to PowerBI Service In PowerShell
Connect-PowerBIServiceAccount
# Get all Workspaces from the Organization that start with UK.
$UKWorkspaces = Get-PowerBIWorkspace -scope Organization -all | Where-Object {$_.name -like 'UK*'}
# For Each Workspace workout the Datasets and the Datasources that correspond to them.
@win2000b
win2000b / PowerBIDataSourceChangeBatch.ps1
Last active October 24, 2022 16:38
Take OwnerShip of PowerBI Dataset, Change Datasource and then output result
# Connect to PowerBI Service In PowerShell
Connect-PowerBIServiceAccount
# Import the Data File for all the PowerBI Datasets you want to change.
$src = Import-CSV "c:\temp\DataImport.csv"
foreach ($line in $src) {
$GetURL = "https://api.powerbi.com/v1.0/myorg/groups/$($line.WorkSpaceID)/datasets/$($line.DatasetID)/datasources"
$TakeOwnURL = "https://api.powerbi.com/v1.0/myorg/groups/$($line.WorkSpaceID)/datasets/$($line.DatasetID)/Default.TakeOver"
$SubmitURL = "https://api.powerbi.com/v1.0/myorg/groups/$($line.WorkSpaceID)/datasets/$($line.DatasetID)/Default.UpdateDatasources"
@win2000b
win2000b / GetASRVaultSettings.ps1
Created July 30, 2019 10:24
Get ASR Vault Settings
$dnsname = "Whatever"
$dt = $(Get-Date).ToString("M-d-yyyy")
$cert = New-SelfSignedCertificate -DnsName $dnsname
$certficate = [Convert]::ToBase64String($cert.RawData)
$VaultFile = Get-AzRecoveryServicesVaultSettingsFile -SiteRecovery -Vault $vault -Certificate $certficate.ToString()
Import-AzRecoveryServicesAsrVaultSettingsFile -Path $VaultFile.FilePath
$cert | Remove-Item
@win2000b
win2000b / AzureSiteRecoveryLogAnalytics.ps1
Last active March 21, 2020 05:38
Azure Site Recovery Log Analytics Query
# Replication Provider Name
# Azure to Azure = A2A
# VMware to Azure = InMageAzureV2
# List All VMware to Azure Replication Jobs and the Max RPO value in the last 3 days
AzureDiagnostics
| where replicationProviderName_s == "InMageAzureV2"
| where TimeGenerated > ago(72h)
| where isnotempty(name_s) and isnotnull(name_s)
@win2000b
win2000b / PowerBIDataSourceChange.ps1
Last active July 19, 2019 12:29
Bulk change PowerBI Datasets to new source
# Insert AAD Client ID below
$clientId = "Insert Azure AD Application Client ID In Here."
# Calls the Active Directory Authentication Library (ADAL) to authenticate against AAD
function GetAuthToken
{
if(-not (Get-Module AzureRm.Profile)) {
Import-Module AzureRm.Profile
}
$redirectUri = "urn:ietf:wg:oauth:2.0:oob"
@win2000b
win2000b / GetPowerBIDataSets.ps1
Created July 18, 2019 11:28
Get All PowerBI Workspaces and the Datasets and What Datasource they use.
# Login to PowerBI Service
Connect-PowerBIServiceAccount
# Get all Workspaces from the Organization that start with UK.
$UKWorkspaces = Get-PowerBIWorkspace -scope Organization -all | Where-Object {$_.name -like 'uk*'}
# For Each Workspace workout the Datasets and the Datasources that correspond to them.
foreach ($workspace in $UKWorkspaces)
{
$ukdatasets = $workspace | Get-PowerBIDataset -scope Organization
@win2000b
win2000b / PowerBIGatewayStatus.ps1
Created July 17, 2019 08:12
Check Power BI Cluster Node Status
# Open Elevated PowerShell. Change into Gateway Directory
cd 'C:\Program Files\On-premises data gateway\'
# Set Execution Policy
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force
# Import Gateway PowerShell Module
Import-Module .\OnPremisesDataGatewayHAMgmt.psm1
# Login as PowerBI Administrator
@win2000b
win2000b / AutoMountIntune.ps1
Last active July 5, 2019 07:55
AutoMount SharePoint Library via Intune PowerShell
$tenantAutoMountRegKey="HKLM:\SOFTWARE\Policies\Microsoft\OneDrive\TenantAutoMount"
$autoMountTeamSitesList= @{
#Enter your SharePoint libraries to configure here as key/value pairs
Technical="INSERT URL IN HERE"
}
if (-not (Test-Path $tenantAutoMountRegKey)){
New-Item -Path $tenantAutoMountRegKey -Force
}
@win2000b
win2000b / Repair Office.ps1
Created June 27, 2019 09:46
Fix Office Install Remotely via PowerShell
$command64 = @'
cmd.exe /C "C:\Program Files\Microsoft Office 15\ClientX64\OfficeClickToRun.exe" scenario=Repair platform=x64 culture=en-us RepairType=QuickRepair forceappshutdown=True DisplayLevel=False
'@
$command86 = @'
cmd.exe /C "C:\Program Files\Microsoft Office 15\ClientX86\OfficeClickToRun.exe" scenario=Repair platform=x86 culture=en-us RepairType=QuickRepair forceappshutdown=True DisplayLevel=False
'@
if(Test-Path -Path "C:\Program Files\Microsoft Office 15\ClientX64\OfficeClickToRun.exe"){
Invoke-Expression -Command:$command64