Powershell script to set default email for all AD users

Depending on the information stored for the users in the AD, there is two ways this can be accomplished: 1.Set email field and default email in ProxyAddresses according to UserPrincipalName: $users = Get-ADUser -Filter * -properties EmailAddress -SearchBase "ou=Test,ou=Departments,dc=DOMAIN,dc=COM" foreach ($user in $users) { $useremail = $user.UserPrincipalName Set-ADUser $user -Add @{'ProxyAddresses' = ("SMTP:"+$useremail )} -EmailAddress $useremail } 2. Set default email in ProxyAddresses Read more [...]

bash: wp: command not found

| August 4th, 2017


After installing WP-CLI as in here: http://wp-cli.org/

executing wp gives the error:

bash: wp: command not found

For me the problem was that the system didn’t have the directory /usr/local/bin in the PATH, to add it:



export PATH


wp should work now if installed correctly

Find files number and size that were modified within a period of time

#!/usr/bin/env python import os, sys, time from datetime import timedelta, datetime totalFiles1 = 0; totalFilesSize1 = 0; totalFiles2 = 0; totalFilesSize2 = 0; days = 0; daysts = 0; def checkModificationDates(path): global totalFiles1, totalFilesSize1,totalFiles2, totalFilesSize2, days, daysts totalsize1 = float(); files1 = 0; totalsize2 = float(); files2 = 0; for directory, subdirectories, filenames in os.walk(path): for filename in Read more [...]

from Lite SQL database

#!/usr/bin/python # -*- coding: utf-8 -*- import sqlite3 as lite import os, csv, sys, subprocess, hashlib, time from datetime import timedelta, datetime, tzinfo import platform con = lite.connect('files.db') con.text_factory = str with con: for directory, subdirectories, filenames in os.walk('.'): print(directory); cur = con.cursor() cur.execute("SELECT * FROM data where path=:directory COLLATE NOCASE", {"directory":directory}) con.commit() Read more [...]

Extract dates to CSV file

#!/usr/bin/env python import os, csv, sys, subprocess, hashlib, time, pytz from datetime import timedelta, datetime, tzinfo import pytz import tzlocal writer = csv.writer(sys.stdout, quoting=csv.QUOTE_ALL) il = pytz.timezone('Israel') local_timezone = tzlocal.get_localzone() # get pytz timezone with open('file.csv', 'w', newline='', encoding='utf-8') as csvfile: spamwriter = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) for directory, Read more [...]

The Bandwidth will be reduced to 6 Mbps

access-list ACL-Guest extended permit ip object Guest_VLAN any
access-list ACL-Guest extended permit ip any object Guest_VLAN

class-map CM-THROTTLE-Guest
match access-list ACL-Guest

policy-map PM-THROTTLE
class CM-THROTTLE-Guest
police output 6000000 2000
police input 6000000 2000

service-policy PM-THROTTLE interface inside


Backup Cisco Routers and Switches

#!/usr/bin/python import pexpect,sys,string,os,time,subprocess,getpass if len(sys.argv) !=2: print ("usage: backup [user@]hostname") else: input_data = sys.argv[1] data=input_data.split("@") switch_un = data[0] switch_ip = data[1] switch_pw1 = getpass.getpass("Enable Password:") switch_pw2 = getpass.getpass("Privilege Password:") basic_backup_directory = "/tmp/Network_Backups" print ("Please wait ...") try: try: child = pexpect.spawn('ssh %s@%s' % (switch_un, switch_ip)) child.timeout Read more [...]

FreeNas Warning 3

| March 12th, 2017

WARNING: Firmware version 13 does not match driver version 12 for /dev/mpr1. Please flash controller to P12 IT firmware.

After flashing /dev/mpr0, another warning message regarding /dev/mpr1.   Listing all controller details: sas3flash -listall It brought up two different controllers, first one in IT firmware, and the second one in IR mode. I've already downloaded the Driver for my controller which included the IR firmware as well. File name I've downloaded is: 9300_8i_Package_P12_IR_IT_FW_BIOS_for_MSDOS_Windows.zip Copied the file in the Firmware\SAS9311_8i_IR to my freeNas server. Then flashed it Read more [...]

Fix Amazon EC2 SSH login

| November 20th, 2016

Logged out of Amazon instance and SSH is not working

Blocked myself with CSF firewall on a Centos 7 server. With the "Run Command" feature was not available, and no web terminal or VNC console such as the one in digitalocean(https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-console-to-access-your-droplet). After reading around I found out that the only solution is to stop the running instance, detach the volume, create another Linux instance (shouldn't be the same as the running one), then attach the old volume to the newly Read more [...]

Powershell Commands

| October 24th, 2016

Close all opened sessions

Get-PSSession | Remove-PSSession

Remove all variables from session

Get-Variable -Exclude PWD,*Preference | Remove-Variable -EA 0