Archive

Archive for the ‘scripting’ Category

Create Active Directory users with Powershell

April 3, 2013 Leave a comment

Scope

In my test environments I always have to create a couple of users to be able to do performance or functionality tests. Powershell really helps me with this task and I just want to archive this for later.

In the next few paragraphs I show you my method to create hundreds of test users on Windows Server 2012 with Powershell.

Read more…

How to turn the GUI on and off on Windows Server 2012

February 12, 2013 Leave a comment

There is a Windows Server edition which takes less attention that it deserves. This is the Microsoft Windows Server Core. Read more…

Postfix SASL Sender Statistics

January 21, 2013 Leave a comment

In some cases we’d like to know, how much has been sent by our Postfix server on a per account basis.

Read more…

Categories: debian, linux, linux, scripting, ubuntu

Starting and keep running reboot persistent autossh on unix-like systems without root rights

December 31, 2012 Leave a comment

Basic scenario

There are systems:

  • - which can’t be accessed from the public internet. E.g. behind ipv4 NAT and DMZ isn’t an option.
  • - which shouldn’t be access directly from the public internet. So firewal or other access control not suitable.

Solution

I wrote a simple shell script securing continuous running of autossh on unix-like systems.
The script is started by cron in every minutes, so no root rights is required. Allowed cron is necessary for your local user. I didn’t used @reboot because this crontab directive isn’t implemented on many Unix systems.
Autossh secures monitored ssh connection which opens a reversed ssh tunnel. If the connection losts it will be restarted by autossh.

The sshd is listening on the 22022 local port ot the host “sage”. So the my systems can be accessed only via local account of server “sage” which can be accessed from everywhere on the net.

The script

#!/bin/bash
#set -x

HOST=”sage”

AUTOSSH_PATH=”/usr/bin/ssh”
export AUTOSSH_PATH

AUTOSSH_PIDFILE=”/home/miam/bin/autossh.pid”
export AUTOSSH_PIDFILE

PIDFILE=”$AUTOSSH_PIDFILE”
AUTOSSH_CMD=”/usr/bin/autossh”

call_autossh ()
{
“$AUTOSSH_CMD” -M 22023 -N -R 22022:localhost:22 -f “$HOST”
}

self_check ()
{
if [ -f "$PIDFILE" ]; then
PID=`cat “$PIDFILE”`
kill -0 $PID
if [ $? -eq 1 ]; then
return 1
else
return 0
fi
else
return 1
fi
}

self_check
if [ $? -eq 1 ]; then
call_autossh
fi

The crontab entry

* * * * * /home/miam/bin/autossh.sh >> /home/miam/bin/autossh.log 2>&1

The repo

The code can be cloned from github:

https://github.com/miam/keeprun/tree/v0.1

Cache service – define memory allocation

December 17, 2012 Leave a comment

well, at last i got the cmdlets to adjust the memory allocation for the chache service at a given machine:


 $instanceName ="SPDistributedCacheService Name=AppFabricCachingService"
 $serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername}
 $serviceInstance.Unprovision()
 Set-CacheHostConfig -Hostname <HostName> -cacheport 22233 -cachesize <Size in MB>
 $serviceInstance.Provision()</i>

Installing nginx web server with php fpm and mysql on CentOS 6

December 15, 2012 Leave a comment

In this article you will find a way to install NGINX web server and add php supporting.
PHP from version 5.3 got php-fpm included so now it’s relatively easy to get it work with nginx without additional scripting.

Read more…

Categories: centos, linux, linux Tags: , , ,

Check OCS/Lync enabled AD user with PowerShell

December 14, 2012 Leave a comment

The security is important; working for a huge company sometimes causes problems. You get less right, because of the security. If you a normal user, and you would like to check if one of the user enabled for OCS without Admin rights or Universal Server Administrator right. A normal domain user can check it, because the AD readable for all AD users.

Read more…

SharePoint workflow – How to check for empty date field

December 14, 2012 Leave a comment

Recently I’ve had to work a lot with SharePoint workflows. During the implementations I am faced a lot of limitations of the SharePoint 2007. There’s a lot of situations when you need to apply workarounds, otherwise you are not able to achieve the goal. I would like to show you one of these limitations and of course I will present the quick and easy solution as well.

So, there was a workflow step when I had to check whether a date field is empty or not. According to the result I wanted to define different actions. Unfortunately in the Designer was no option for that as you can see below.

Compare

Read more…

How to get the type of the HDD in PowerCLI

December 14, 2012 Leave a comment

I would like to determine each VM HDD type. Is it thin or thick? I realized that this question is not a trivial.

Here are the commands, which gather the type of the disc.


$vm = Get-VM -name testsrv

$thin = (((($vm |get-view).config).Hardware).Device | where {$_.GetType().Name -eq "VirtualDisk"}).Backing.ThinProvisioned
if ( $thin )
{
Write-Host "    Disk provisioning type: Thin"
}
Else
{
Write-Host "    Disk provisioning type: Thick"
}

That’s all!

vCenter Server automated Inventory with PowerCLI

December 13, 2012 Leave a comment

As you can see in my previous articles I created and filled in the Custom Attributes fields. The aim of the whole customization to store all data in the vCenter Server, easily do an automated inventory. The script not needs an SAP connection to gather the required information, because all data available in one information store.

Read more…

Follow

Get every new post delivered to your Inbox.

Join 47 other followers

%d bloggers like this: