Skip to content

Instantly share code, notes, and snippets.

@win2000b
win2000b / Removehold.ps1
Created August 10, 2020 08:48
Remove Holds and then query
$mailboxes = Get-Mailbox
foreach ($mailbox in $mailboxes)
{
set-mailbox $mailbox.Alias -removedelayholdapplied
set-mailbox $mailbox.Alias -removedelayreleaseholdapplied
}
$mailboxes = Get-Mailbox
foreach ($mailbox in $mailboxes)
@win2000b
win2000b / TeamsGuests.ps1
Created July 30, 2020 16:02
Query All Microsoft Teams and Export list of guests
# Connecting to Teams
Connect-MicrosoftTeams
# Connecting to Azure AD
Connect-AzureAD
#Get list of all Teams
$AllTeams = get-team
# For each team extract members
@win2000b
win2000b / DirectBillingToCSP.ps1
Last active August 2, 2022 19:57
Analyse Azure Resources Migration from Direct Billing to CSP
# First of all we are assuming we have delegated rights through CSP
# If we dont have delegated rights we need a login with reader rights in the customers subscription
# We then need 2 things. The Tenant ID of where the source subscription is located
# Then we need the subscription ID for the source subscription.
# If a customer has multiple subscriptions we will need the IDs for each and the script should be run for each.
# If you need to install Azure Module
Install-Module AzureRM
# Define these 2 variables.
@win2000b
win2000b / MSIextract.ps1
Created January 24, 2020 09:00
Get list of all MSI apps installed
get-wmiobject Win32_Product | Format-Table IdentifyingNumber, Name, LocalPackage -AutoSize
@win2000b
win2000b / EdgeBookmarks.json
Created December 5, 2019 16:11
Edge Favourites JSON
[
{
"toplevel_name": "Company Bookmarks"
},
{
"url": "www.Company.co.uk",
"name": "Company Home Page"
},
{
"url": "https://login.citation.co.uk",
@win2000b
win2000b / GetLibraryID.ps1
Last active April 8, 2024 03:40
Get Library ID from SharePoint Document Library for Sync
# Optional, To get your tenant ID via PowerShell
Connect-msolservice
Get-MSOLCompanyInformation | select objectID
# Install SharePoint PowerShell If needed
Install-Module SharePointPnPPowerShellOnline
# Example https://$tenant.sharepoint.com/sites/$siteName
$tenant = 'Enter your Tenant Name in Here' # xxxx.onmicrosoft.com
$tenantId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' #Tenant ID, can be retrieved from Azure AD or PowerShell under optional.
@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 August 10, 2024 09:35
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 August 10, 2024 09:35
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