Image

Image

Search This Blog

Thursday, July 04, 2013

Configure a bunch of HP Thin Clients with fixed IPs

@echo off
:: A script to assign incremental fix ips to Thin Clients
:: Needs psexec (http://live.sysinternals.com/psexec.exe) in order to run with administrative rights
:: 2013/07/04 neXt (s@xxxxxxxx.com) Initial release

:: set variables
setlocal
set user=Administrator
set pass=Administrator
set iprange=192.168.3
set nmask=255.255.255.0
set gateway=192.168.3.254
set dns1=192.168.3.3
set dns2=192.168.1.3
set startip=200

:: we need a common location to save the last used IP.
set "conf=ips.txt"
IF not EXIST %conf% (
echo DEBUG: Config file does not exist! Creating %conf% with the starting IP %iprange%.%startip%
(echo %startip%)>"%conf%"
)

:: get the saved IP and increment it by 1
for /f "usebackq delims=." %%N in ("%conf%") do set /a newip=%%N+1
if %newip% GTR 254 (
echo IP can not be bigger than 254! Please Check the IP Range!
pause
exit /B


:: put back the new IP 
(echo %newip%)>"%conf%"

:: in order to change the IP, we need to identify the local network adapter name
For /f "skip=2 tokens=4*" %%a In ('NetSh Interface IPv4 Show Interfaces') Do (

Call :UseNetworkAdapter %%a "%%b"
)

Goto :End

:UseNetworkAdapter
:: varibles: %1 = State; %2 = Name (quoted); %~2 = Name (unquoted)
If %1==connected (

:: Ignore Loopback interface
echo.%2|findstr /C:"Loop" >nul 2>&1
if errorlevel 1 (

echo DEBUG: Interface: %2 IP: %iprange%.%newip% Mask: %nmask% GW: %gateway% DNS: %dns1% %dns2%
psexec -u %user% -p %pass% netsh interface ip set address name=%2 static %iprange%.%newip% %nmask% %gateway% 1
psexec -u %user% -p %pass% netsh interface ip set dns name=%2 static %dns1%
psexec -u %user% -p %pass% netsh interface ip add dns name=%2 %dns2% index=2

:: save the thin client state and reboot
psexec -u %user% -p %pass% ewfmgr c: -commit
psexec -u %user% -p %pass% shutdown -r -f -t 2
))

:End
endlocal

Monday, May 20, 2013

Query all packages installed from 3rd party repositories

rpm -qa --qf '%{NAME} %{VENDOR}\n' | grep -v Mageia

Saturday, February 02, 2013

Move Local Computer to a different OU

On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Set WshNetwork = WScript.CreateObject("WScript.Network")
set objOU = GetObject(LDAP://ou=localComputers,ou=SOME_OU,dc=domain,dc=local)
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _"SELECT ADsPath FROM 'LDAP://dc=domain,dc=local' WHERE objectCategory='computer' " & _"AND Name='" & wshNetwork.ComputerName & "'"

'Wscript.Echo " " & wshNetwork.ComputerName
Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst
Do Until objRecordSet.EOF
strADsPath = objRecordSet.Fields("ADsPath").Value objOU.MoveHere strADsPath, vbNullString
objRecordSet.MoveNext
Loop

Wednesday, January 02, 2013

Tehnium 08-09/1995 (romanian language) :)

Yes, there was a time when I was doing everything analog. Then it came a time when even my audio amplifiers where "Class D" and I designed way smarter digital security systems based on real microcontrollers (among many other things), but I will always remember with pleasure my first successful (as in "I sold more than 10" :) ) product:

Friday, December 07, 2012

Add all Domain Users to Local Administrators (French or English)

Option Explicit
Dim owShell, oWMI, colOperatingSystems, oOS, strComputer, strUser, strDomain, objLocalAdminGroup, sComputer, iOSLang, strAdmins  
On Error Resume Next
Set oWShell = CreateObject("Wscript.Shell")
strComputer = oWShell.ExpandEnvironmentStrings("%computername%")
strDomain = oWShell.ExpandEnvironmentStrings("%userdomain%")
'strUser = strDomain & "\" & oWShell.ExpandEnvironmentStrings("%username%")
strUser = strDomain & "\Domain Users"
Set oWMI = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer _
    & "\root\cimv2")
Set colOperatingSystems = oWMI.ExecQuery _
    ("Select * from Win32_OperatingSystem")
For Each oOS in colOperatingSystems
  iOSLang = oOS.OSLanguage
Next
If iOSLang = "1033" Then
strAdmins = "/Administrators"
Else
strAdmins = "/Administrateurs"
End if
Set objLocalAdminGroup = GetObject("WinNT://" & strComputer & strAdmins)
objLocalAdminGroup.Add("WinNT://" & Chr(34) & strUser & Chr(34))
Set objLocalAdminGroup = Nothing

Saturday, November 17, 2012

BES - enable http auth

Because the BlackBerry browser uses the BES server to render the pages, the default user for integrated authentication is always "besadmin"
In order to allow the user to authentify itself, we must enable Authentication support on the MDS. Follow KB15642 on bb site  or just

 For BlackBerry Enterprise Server 4.1:
         1. In BlackBerry Manager, select <BlackBerry_Enterprise_Server_name>_MDS-CS_1.
         2. Click Edit Properties. 
         3. In the Properties window, click HTTP.
         4. Under Authentication set the Support HTTP Authentication to True.


  For BlackBerry Enterprise Server 5.0
         1. Open the BlackBerry Administration Service.
         2. Expand the BlackBerry Solution topology.
         3. Expand the component view.
         4. Select MDS connection service.
         5. Select the http tab.
         6. Set authentication support enabled to yes.
         7. If you change this configuration, you will need to restart the BlackBerry MDS service in the Windows Services window.

Configure the MDSLogin.conf file to include your domain name. This will populate the domain field for the BlackBerry smartphone user when they are prompted for credentials on their BlackBerry smartphone. Complete the following steps:

1.On the BlackBerry Enterprise Server, go to C:\Program Files\Research In Motion\BlackBerry Enterprise Server\MDS\Servers\servername\config. 
2.Open the MDSLogin.conf file in a text editor. 
3.Edit the MDS_Default section by replacing COMPANY.COM with your domain name.

Note: If the domain name starts with a number, surround the domain name with quotes ("")

4.If you wish to force a particular authentication type you can change the relevant optional entry to required. 
 
 Save and close the file.
 
C. Configure the krb5.conf file to include details relevant to your specific Microsoft Active Directory environment as follows:
    On the BlackBerry Enterprise Server navigate to C:\Program Files\Research In Motion\BlackBerry Enterprise Server\MDS\Servers\servername\config. 
 

1.Open and edit the krb5.conf in a text editor.

The default sections and entries contained within this file are as follows:
[libdefaults]
default_tkt_enctypes = des-cbc-md5 ; or des-cbc-crc
default_tgs_enctypes = des-cbc-md5 ; or des-cbc-crc
[realms]
# change COMPANY.COM to your Kerberos realm
# change KDC:88 to the hostname:port of KDC
COMPANY.COM = {
kdc = your_kdc.your_domain.com:88} 
2.Replace the COMPANY.COM entry under the [realms] section with your domain name. Ensure this entry is in UPPER case.  
3.Enter the Fully Qualified Domain Name (FQDN) of the KDC within your Microsoft Active Directory environment and port number (if changed from the default of 88). Ensure host names and domain names are in lower case.  
4.Restart the BlackBerry MDS Connection Server service in Windows Services

Wednesday, October 17, 2012

7

- putem dezgropa mortii acum :)

Saturday, October 06, 2012

Remove weird characters from filenames


paste <(find . -print | awk '{print "\042"$0"\042"}') <(find . -print | sed -e 's/\o300/A/g' -e 's/\o301/A/g' -e 's/\o302/A/g' -e 's/\o340/a/g' -e 's/\o341/a/g' -e 's/\o342/a/g' -e 's/\o307/C/g' -e 's/\o347/c/g' -e 's/\o310/E/g' -e 's/\o311/E/g' -e 's/\o312/E/g' -e 's/\o350/e/g' -e 's/\o351/e/g' -e 's/\o352/e/g' -e 's/\o316/I/g' -e 's/\o356/i/g' -e 's/\o322/O/g' -e 's/\o323/O/g' -e 's/\o324/O/g' -e 's/\o362/o/g' -e 's/\o363/o/g' -e 's/\o364/o/g' -e 's/\o331/N/g' -e 's/\o361/n/g' -e 's/\o331/U/g' -e 's/\o332/U/g' -e 's/\o333/U/g' -e 's/\o371/u/g' -e 's/\o372/u/g' -e 's/\o373/u/g' -e 's/\o357/i/g' -e 's/\o317/I/g' -e 's/\o264/_/g' -e 's/\o250/_/g' -e 's/[)(]/-/g' -e 's/^\(.*\)$/"\1"/') | sed -e 's/^/mv /'

pretty neat, heh?
I'm using awk when I define the source because sed -e 's/.*/"&"/' or 's/^\(.*\)$/"\1"/' fails in the weird characters.

 And while being there, find . -type f -regextype posix-extended ! -iregex '.*.(mp3|avi|mkv|wmv|mp4|mp5|flv|M4V|mpeg|mov|m1v|m2v|3gp|avchd)$' -delete will nicely clean up the music folders :)


the characters definitions are found in  /usr/share/X11/locale/iso8859-1/Compose

Blog Archive