This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function New-MSGraphAPIToken { | |
<# | |
.SYNOPSIS | |
Acquire authentication token for MS Graph API | |
.DESCRIPTION | |
If you have a registered app in Azure AD, this function can help you get the authentication token | |
from the MS Graph API endpoint. Each token is valid for 60 minutes. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#REGION VARIABLES | |
#// username (domain\username) | |
$uname = "domain\user" | |
#password - plain text | |
$passwd = "p@ssw0rd" | |
#// remote computer where the files to be copied are hosted | |
$remoteSourceComputer = "server01" | |
#// source folder from the remote computer (DO NOT USE UNC PATH) | |
$remoteSourceFolder = "C:\SourceFolder" | |
#// destination folder on the local machine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#create an empty array for the final result | |
$finalResult = @() | |
#get mailboxes as per your requirement | |
$mailboxes = Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize Unlimited | Sort-Object UserPrincipalName | |
#loop through each object | |
foreach ($mailbox in $mailboxes) { | |
Write-Host "Reading:" $mailbox.UserPrincipalName | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#must have MicrosoftPowerBIMgmt module installed (Install-Module -Name MicrosoftPowerBIMgmt) | |
#must have PowerBI Admin rights | |
#must be connected to PowerBI as admin | |
$credential = Get-Credential | |
Connect-PowerBIServiceAccount -Credential $credential | |
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $credential -Authentication Basic -AllowRedirection | |
Import-PSSession $Session -DisableNameChecking | |
$pbws = Get-PowerBIWorkspace -Scope Organization -ALL | Sort-Object Name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Output file for report | |
fileOutput = "Allow_RelayIP.txt" | |
' The Vitual SMTP Server ID | |
vistualSMTPServer = "IIS://localhost/smtpsvc/1" | |
Set fso = CreateObject("Scripting.FileSystemObject") | |
Set allowFile = fso.opentextfile(fileOutput,2,true) | |
Set objSMTP = GetObject(vistualSMTPServer) | |
Set objRelayIpList = objSMTP.Get("RelayIpList") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function GetIISSmtpRelayIPList { | |
param ( | |
# virtual smtp server name | |
[parameter()] | |
[string]$smtpName = "SmtpSVC/1", | |
# computer name | |
[parameter()] | |
[string]$computerName = $env:COMPUTERNAME | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-MSGraphOAuthToken { | |
<# | |
.SYNOPSIS | |
Acquire authentication token for MS Graph API | |
.DESCRIPTION | |
If you have a registered app in Azure AD, this function can help you get the authentication token | |
from the MS Graph API endpoint. Each token is valid for 60 minutes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ShellApp = New-Object -ComObject ShellApp.Application # initialize the COM application object | |
foreach($i in $(0..100)){ # from 0 to 100. The highest number is just a guess. | |
$ShellApp.namespace($i) | Where-Object {$_.Title} | # try the namespace, and return only if there's value in title | |
Select-Object ` | |
@{n="Dec";e={$i}}, ` # Base 10 (Dec) namespace index | |
@{n="Hex";e={"0x" + ('{0:X}' -f $i)}}, ` # Base 16 (Hex) namespace index | |
Title, ` | |
@{N="Path";e={$_.Self.Path} } # Folder path | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Function to recursively list group members (nested) | |
Function Get-MembersRecursive { | |
param ( | |
[parameter()] | |
[string]$RecipientName | |
) | |
$groupMembers = @() | |
$group = Get-Group $RecipientName -ErrorAction SilentlyContinue | |
foreach ($groupMember in $group.Members) { | |
$memberObj = Get-Recipient $groupMember -ErrorAction SilentlyContinue |
OlderNewer