Friday, August 24, 2018

Skype for Business - Powershell to set Dialplan Policy & Voice Policy to Automatic.

If you had manually assigned DialPlan & VoicePolicy and started using the Site level policy then you might want to change your DialPlan & VoicePolicy for all users to back to Automatic.


Basically from 

To 


Here is the powershell which targets users via RegisterPool. I also make a backup of dialplan & volicepolicy which was assigned to user in csv.

Import-Module SkypeOnlineConnector
#Change the below pool for targeting users
$RegistrarPool = "frontend.domain.com"

$users = Get-CsUser -Filter {RegistrarPool -eq $RegistrarPool} | select DisplayName 

$array = @()

foreach ($user in $users)
{

$userpolicy = get-csuser $user[0].DisplayName | select DisplayName, VoicePolicy, DialPlan

$array += $userpolicy

get-csuser $user[0].DisplayName | Grant-CsDialPlan -PolicyName ""
get-csuser $user[0].DisplayName | Grant-CsVoicePolicy -PolicyName ""

#Dialplan set
#get-csuser Firstname LastName | Grant-CsDialPlan -PolicyName ""
#VoicePolicy set
#get-csuser firstname.lastname@skype.com | Grant-CsVoicePolicy -PolicyName ""
}
$array | Export-Csv -notype -Path C:\Scripts\dialplanpolicyFinal-+$RegistrarPool+.csv

Friday, July 14, 2017

Remove roaming profile and free up space on server

You can free up space by deleting user profiles to save space on the server.

Shortcut cmd is rundll32 sysdm.cpl,EditUserProfiles


Wednesday, July 27, 2016

Skype For Business - Reports for Users with Enterprise Voice Enabled and their Extensions.

Skype For Business 2015 - Reports for Users with Enterprise Voice Enabled and their Extensions.

#Create table and populate users properties
$table = @()

#Get users who have Enterprise Voice Enabled and select Name, LineURI and #EnterpriseVoiceEnabled columns
$users = Get-CsUser -Filter {EnterpriseVoiceEnabled -eq $true} | `
Select DisplayName, LineURI, EnterpriseVoiceEnabled

#Loop through each users
foreach($user in $users){

#Get Name from the user list for each user
$name = $user.DisplayName
#Grab extension which is after = sign and grab the 1st part after =
$ext = $user.LineURI.Split("=")[1]
#Grab value of EnterpriceVoiceEnabled in this case it will be always True
#cause our initial search only includes Enterprise Enabled users.
$entvoice = $user.EnterpriseVoiceEnabled


#Add each columns with property for users.
$objAverage = New-Object System.Object
$objAverage | Add-Member -type NoteProperty -name "User" -value $name
$objAverage | Add-Member -type NoteProperty -name "Extension" -value $ext
$objAverage | Add-Member -type NoteProperty -name "Enterprise Voice" -value $entvoice

#Add them to table
$table += $objAverage

#Format the table. This is useless as we are sending email from below $body
$table | Format-Table -AutoSize
}

#CSS formating
$a = "<style>"
$a = $a + "BODY{background-color:white;}"
$a = $a + "TABLE{border-width: 2px;border-style: solid;`
border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 2px;padding: 2px;`
border-style: solid;border-color: black;background-color:GoldenRod}"
$a = $a + "TD{border-width: 2px;padding: 2px;border-style: `
solid;border-color: black;background-color:palegoldenrod}"
$a = $a + "</style>"

##############Change your SMTP Details Start###
#Your SMTP server
$smtpServer = "intermailserver.usyse.com"

#Your from address
$from = "Do_Not_Reply@usyse.com"

$To = "me@usyse.com", "you@usyse.com"
$CC = "someone@usyse.com"

##############Change your SMTP Details Ends### 
$Subject = "Skype For Business Extensions"

$Body  = "Skype For Business Extension Details<br>

 <br>
"
#Here I am sorting it out with Extension
$Body  += $table  | Sort-Object Extension | ConvertTo-Html -head $a
$Body  += "<br><br>"
#$message.Body  += " <br>"
#$message.Body  += " <br>"
$Body  += " "


#Send email finally

Send-MailMessage -To $to  -Subject $subject -Body $body -SmtpServer $smtpserver -From $from -BodyAsHtml  -Cc $CC

Thursday, March 5, 2015

Office 365 - Give permission to a someone for all calendars



Following powershell will list mailbox with resource type as "Room" and then it will add user@domain.com as Editor for that rooms calendar.



$rooms = get-mailbox | where {$_.resourcetype -eq "room"}
foreach ($room in $rooms)
{
Add-MailboxFolderPermission -Identity ($room.windowsliveid + ":\calendar") -user user@domain.com -AccessRights Editor

}

Thursday, August 15, 2013

Show more details in Calendar (Room Mailbox)

If you made a Room Mailbox for a meeting room and someone wants to see who booked it and more details for that booking you can run the following cmdlet to change the default setting to Reviewer which will give end user more information about that booking.


Set-MailboxFolderPermission meetingroom:\Calendar -User Default -AccessRights Reviewer

Wednesday, August 14, 2013

List users in security group.

So group you want to target is vpn_users and you want to output to a text file called vpnusers.txt.

1st option is very detailed and has OU information in it. 2nd option is on the fly kind of deal and useful for just looking at members.


dsquery group -name "vpn_users" | dsget group -members -expand > c:\vpnusers.txt

Or

net group vpn_users /domain > c:\vpnusers.txt

Also you might like net user ijaved/domain command as well :) I love it to check details like if account has expired password or account is locked. Saves me from going into AD and checking Account tab.

Password Expiry Notification - Powershell Script

Here's a powershell script to send out email to end user to remind them of password expiry.

Feel free to use it. It's not the best method but it gets the work done for me. If you make it better please post it back so it can help other users.




# ======================================

# = Password Expiry Email Notification =

# ======================================

# Created: [10/10/2013]

# By ijaved
$smtpSrv = "smtp.server.com" #Name of your exchange server.
$emailDomain = "@server.com" #Your email domain
$emailUser = "helpdesk" #Needs this to authenticate before sending email.
$emailPass = "HelpDeskPwd" #Pass for above user.
$emailFrom = helpdesk@server.com #Sender Email Address
$adminEmail = alerts@server.com #CC admin on email sent to user.
$owaUrl = "https://owa.server.com/owa" #OWA URL needed for email msg
$groupName = "RemoteUsers" #Name of security group where user will be picked up from.




#Function Mail Users
 
 
Function mail {
$smtpserver = $smtpSrv
$msg = new-object Net.Mail.MailMessage
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.EnableSsl = $True
$smtp.Credentials = New-Object System.Net.NetworkCredential($emailUser, $emailPass);
$msg.From = $emailFrom
$msg.To.Add($email)
$msg.CC.Add($adminEmail)
$msg.Subject = “Password Expiry Notice!”
$msg.Body = “Hi "+ $fullName +",





 
 
You have $calExpire days left to change your password. Your password will expire on $formatDate.




You can either do it by pressing <CTRL><ALT><DELETE> and then clicking Change Password button or from OWA.

To change it from OWA please follow the below steps :-
 
 
1. Open any Web browser and type $owaUrl in the address bar.




2. Log in using your credentials.

3. Once you are logged in, click on Options, located at the top right hand corner of OWA.

4. Drop down menu will display multiple option. Click on Change Your Password.

5. Enter your former password as well as your new password, and then click on Save.

6. Outlook Web Access will tell you that your password has been successfully changed. Click on OK to log in with your new password.

Best Regards,

HelpDesk"
 
 

$smtp.Send($msg)



}
 
#End Function Mail
 
 




#Users in an array for testing. Add multiple like this "test","test2"

#$users = "jiqbal"
 
 




#Users from domain group
 
 
$pickUser = net group $groupName /domain | out-string

$users = (($pickUser -split "(-{79})|(The command completed successfully.)")[2]) -split "\s+"




#Loop through $users and get each user and run.
 
 
foreach ($user in $users)



{
 
#Check if $user is not empty
 
 
If (!$user){Continue}

Else {



#Execute net user command with username
 
 
$result = net user $user /domain



#Get Firstname of user by selecting string with "Full Name"
 
 
$fName = $result | select-string "Full Name"



#Split at space and drop empty spaces with where-object (where object is not equal to space) collect word 4 & 5 (Firstname & Lastname)
 
 
$filternames = $fName.tostring().split("") | where-object {$_ -ne ""}



#Pick Names from the array 2 & 3
 
 
$name = $filternames[2,3]



#Join the two together
 
 
$fullName = [string]::Join(" ", $name)




#Creating email by adding Firstname.Lastname
 
 
$email = [string]::Join(".", $name) + $emailDomain




#Get password expiry date by searching "Password expires"
 
 
$pwdexpires = $result | select-string "Password expires"




#Split at space and collect array 2 which is the password expiry date
 
 
$formatDate = $pwdexpires.tostring().split(" ") | where-object{$_ -ne ""} ; $formatDate = $formatDate[2]




#If password never expired is selected then you will get error. Skip the user by using if statement
 
 
If ($formatDate -eq "Never"){Write-Host -f red "Skipping $user : Password never expires selected."; Continue}
Else{



#Changing format for expireDate and assigning todays date.
 
 
$expiryDate = Get-Date -Date $formatDate; $today = Get-Date




#Calculate days left to reset by - expiry date with current date. (expiry date will be in future)
 
 
$calExpire = ($expiryDate - $today).days



}
 
#Notify admin about expiry date if its less than 14
 
 
If ($calExpire -le 14){
Write-Host "$fullName has $calExpire days left to change his password. His password will expire on $formatDate."


}
 
#If expiry date is equal to 7 / 3 / 1 then go ahead and send email notification to user.
 
 
If ($calExpire -le 7){mail}
ElseIf ($calExpire -eq 4){mail}
ElseIf ($calExpire -eq 3){mail}
ElseIf ($calExpire -eq 2){mail}
ElseIf ($calExpire -eq 1){mail}
Else {Write-Host -f green "$fullName has $calExpire days left"}



}

}