<#


 AUTHOR: Rasmus Schmidt
 EMAIL: rsc@itafdelingen.dk

For bulk renaming files, creates a logfile on the script path.
Asks the user for a path to the folder containing the files and what to remove of the filename
create the log file in the same location as the script with info on the renamed files

 
#>

[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null
Add-Type -AssemblyName PresentationFramework
$msgBoxInput = [System.Windows.MessageBox]::Show('Warning, this script renames all files in the directories in the path you enter, Continue?','Warning','YesNoCancel','Error')

switch  ($msgBoxInput) {
'Yes' {

$filepath = [Microsoft.VisualBasic.Interaction]::InputBox("Write path to top level directory", "Filepath", "")
$removestring =[Microsoft.VisualBasic.Interaction]::InputBox("Write the part you want to remove", "Filename", "")

$path = split-path -parent $MyInvocation.MyCommand.Definition
$log = "$path\RenamedFiles.log" 
$date = Get-Date -format F
"Renamed the following files (on. " + $date + "): " | Out-File $log -append 
"--------------------------------------------" | Out-File $log -append 

$files = Get-ChildItem -Filter * $filepath -recurse | where {$_.Name -like "*$removestring*"}

foreach ($file in $files) {
      
         Rename-Item -Path $file.FullName $file.name.Replace($removestring,"") -ErrorAction Stop
         $newname = $file.name.Replace($removestring,"")
         $output = "Renaming $file to $newname"
         $output | Out-File $log -append
         }
}

'No' {
Write-host "Thank you!"
    }

}

 

get-mailbox | where {$_.WindowsEmailAddress -eq "user@domain.com"} | Add-MailboxPermission -User "user_who_need_access" -AccessRights FullAccess -InheritanceType All

or

Add-MailboxPermission -Identity user@domain.com -User "user_who_need_access" -AccessRights FullAccess -InheritanceType All
get-mailbox | where {$_.WindowsEmailAddress -eq "user@domain.com"} | Add-ADPermission -User "user_who_need_access" -ExtendedRights "Send As"

or

Add-ADPermission -Identity "user@domain.com" -User "user_who_need_access" -ExtendedRights "Send As"

 

A few scripts to set, copy and check the Pager attribute in ActiveDirectory, very usefull for SMSPasscode

$members = Get-ADGroupMember "HSH-SMS With License"

foreach ($member in $members) {
$user = Get-ADUser $member -Properties pager
$pager = $user.pager
if ($pager -eq $null)
    {
    write-host "pager for $user is blank"
    }
                            }

 

$members = Get-ADGroupMember "HSH-SMS Without License"

foreach ($member in $members) {
$user = Get-ADUser $member -Properties pager
$pager = $user.pager
if ($pager -eq $null)
    {
    write-host "pager for $user is blank"
    $user.pager = "12345678"
    Set-ADUser -instance $user
    }
                            }

 

$members = Get-ADGroupMember "HSH-SMS With License"
foreach ($member in $members) {
$user = Get-ADUser $member -Properties pager,mobile
$pager = $user.pager

if ($pager -ne "12345678")
    {
    
    $user.mobile = "+45$pager" #set mobile as pager number with +45 in front
    $user.SamAccountName #output user 
    $user.mobile  #output mobile number
    Set-ADUser -instance $user #write the attribute to AD
    }
                            }