0

Set Simple Queue Burst Rates

by Jim Bouse 30. September 2012 19:56

I have a Mikrotik router as my bandwidth limiter for my ISP.  I use Simple Queues for each IP to assign them to a speed.  I recently decided to be nice and add bursting to the plans.  I decided that the customers would get 2X their purchased speed for 16 seconds (a standard time window).  Since I had about 100 IPs and Simple Queues, I defanately did not want to manually add bursting to my Simple Queues.  I wrote the following script.  It will loop through all your simple queues and add the 2X burst amount.

You can download the .txt here in case the formatting gets screwed up. - setSimpleQueueBurst.txt (1.46 kb)

:local rate
:local inboundrate
:local outboundrate
:local inboundburstrate
:local outboundburstrate
:local inboundburstthreshold
:local outboundburstthreshold
:local ip
 
/queue simple
:foreach i in=[find] do={
  :set ip [get $i target-addresses]
  :set rate [get $i max-limit]
  :set inboundrate [:pick $rate ([:find $rate "/"]+1) 999 ]
  :if ([:find [:tostr $inboundrate] "k" ] > 0) do={
    :set inboundrate ([:pick $inboundrate 0 [:find [:tostr $inboundrate] "k" ]]*1000)
  }
  :if ([:find [:tostr $inboundrate] "M" ] > 0) do={
    :set inboundrate ([:pick $inboundrate 0 [:find [:tostr $inboundrate] "M" ]]*1000000)
  }
  :set outboundrate [:pick $rate 0 ([:find $rate "/"]+1)]
  :if ([:find [:tostr $outboundrate] "k" ] > 0) do={
    :set outboundrate ([:pick $outboundrate 0 [:find [:tostr $outboundrate] "k" ]]*1000)
  }
  :if ([:find [:tostr $outboundrate] "M" ] > 0) do={
    :set outboundrate ([:pick $outboundrate 0 [:find [:tostr $outboundrate] "M" ]]*1000000)
  }
  :set inboundburstrate ($inboundrate*2)
  :set outboundburstrate ($outboundrate*2)
  :set outboundburstthreshold ($outboundrate*2)
  :set inboundburstthreshold ($inboundrate*2)
  :set inboundrate ($inboundrate/5)
  :set outboundrate ($outboundrate/5)
  
  set $i limit-at="$outboundrate/$inboundrate" burst-time="16s/16s" burst-threshold="$outboundburstthreshold/$inboundburstthreshold" burst-limit="$outboundburstrate/$inboundburstrate"
  :put "Set $ip simple queue burst."
 
}

Tags: , ,

Mikrotik | WISP

0

PowerShell - Disable user access to mailbox while still alllowing mailbox to function.

by Jim Bouse 9. November 2011 15:47

After I migrated my hundreds of users, I had some that were refusing to quit using the old webmail address.  We were retiring the URL and therefore we couldn't just stick it on the new OWA server.  To fix this, I disabled ActiveSync (for phones), OWA, and MAPI (for Outlook).

The code is as follows:

Get-Mailbox -OrganizationalUnit "Some OU" -DomainController "Some DC" | Set-CASMailbox -OWAEnable:$false -ActiveSyncEnabled:$false -MAPIEnabled:$false

A few days after this change, a couple of the stragglers relunctantly started using the new OWA.... and liked it. 

Tags: , , , ,

PowerShell

0

PowerShell - Create AD Groups then Populate Them from CSV

by Jim 16. October 2011 17:57

In my previous post, I explained how to export a .CSV for each group in an OU.  This gives you a .CSV for each group which is named the same as the group name.

  • Some Group 1.csv
  • Some Group 2.csv
  • Some Group 3.csv
  • Some Group N.csv

Now, I need to create those Groups in a new AD.  Here is the script that I used:

Get-ChildItem | foreach { echo $_.Basename } | ForEach-Object { dsadd group -scope u "cn=$_,OU=Groups,OU=Some OU,DC=SubDomain,DC=Domain,DC=TLD" }

This script calls the program DSADD and passes it the correct name (minus the .csv) which is then used to create the Groups.

Next, we run a similar script that walks through those same .CSV's and adds the users to the group with the same name as the .CSV.

Get-ChildItem | foreach { $GN = $_.BaseName; Import-Csv $_ } | foreach { Add-ADGroupMember -Identity $GN -Members $_.SamAccountName }

This works wonderfully well if the column titled SamAccountName has the correct usernames in it.

Tags: , , , ,

PowerShell

0

PowerShell - Export Group Members to CSV

by Jim Bouse 16. October 2011 16:52

This script will export a .CSV for each group in an OU.  The CSV will be named the same as the group name.

Use this code on an Exchange Server:

Get-Group -OrganizationalUnit "Some OU" | ForEach-Object { Get-Group -Identity $_.Name | ForEach { $_.Members } | Get-User | Export-Csv ($_.Name + '.csv') }

 

Use this code on an machine with Import-Module ActiveDirectory loaded:

Get-ADGroup -OrganizationalUnit "Some OU" | ForEach-Object { Get-ADGroup -Identity $_.Name | ForEach { $_.Members } | Get-ADUser | Export-Csv ($_.Name + '.csv') }

* Greg Martin suggested I clear this up...  Thanks!

Tags: , , , , ,

PowerShell

0

PowerShell - Add Users to Group from CSV

by Jim 16. October 2011 14:56

I needed to add users to groups by PowerShell and was having trouble finding examples how to do it.  Here is how I figured it out.

First, you need a CSV of the users's logon names.  My list came from the CSV from:

Get-DistributionGroupMember -Identity 'Some List' | Export-Csv 'list.csv'

The list generated above consisted of alot of fields.  The only one I am interested in for this use is "Alias".  Once I had the list generated from my old AD, I then ran:

Import-Csv 'list.csv' | ForEach-Object { Add-ADGroupMember -Identity "Some New Group Name" -Members $_.Alias }

Remember the script above needs to be a single line.  I had to break it apart so it will fit in the blog format.  It worked like a charm.

Tags: , , , ,

PowerShell

0

PowerShell - Export Mailbox Users to CSV

by Jim 16. October 2011 13:03

This script exports users from an OU to a CSV that can be used by other scripts.  I had to move hundreds of users from one domain to another and modify some user properties during the process.  A CSV file allows you to open the file in Excel and edit the fields as needed.  You can take the output of this script and use it to create uses in a new domain with this script.

Get-Mailbox -OrganizationalUnit "User OU" | Export-Csv -f User_Mailboxes.csv

Export details for all mailboxes for user in OU.txt (76.00 bytes)

Tags: , , , ,

PowerShell

0

PowerShell - Create Users from CSV

by Jim 16. October 2011 11:23

This script creates users via Powershell.  I had to create 500 users in a new Active Directory domain that I had previously exported from an old domain.  This script can be run from the command line in PowerShell.  I have attached a .TXT file with the script if you would like to download it.

You will need a .CSV file with the following columns:

  • Alias
  • UPN
  • Name
  • DisplayName
  • FirstName
  • LastName
  • OU

Import-Csv 'Users.csv' | ForEach-Object { New-ADUser -SamAccountName $_.Alias -UserPrincipalName $_.UPN -Name $_.Name -DisplayName $_.displayname -GivenName $_.FirstName -Surname $_.LastName -Path $_.OU -AccountPassword (ConvertTo-SecureString "Some!Password" -AsPlainText -Force) -Enabled $true -PasswordNeverExpires $false -PassThru } > Import.log

Create users from CSV.txt (349.00 bytes)

Tags: , , , ,

PowerShell

Powered by BlogEngine.NET 2.5.0.6
Original Design by Laptop Geek, Adapted by onesoft