Wednesday 10 October 2012

Could not start the net logon service

c:\>netsh winsock reset

Network card not getting an IP address

or more accurately...

When I attempt to logon to a domain I just joined I
cannot and when i go into services the net logon service
is stopped I attempt to start it and get this message -

Could not start the net logon service on the local
computer. Error 10106: The requested service provider
could not be loaded or initialized.
Solution:
How to determine and to recover from Winsock2 corruption in Windows Server 2003, in Windows XP, and in Windows Vista

http://support.microsoft.com/?kbid=811259

Tuesday 9 October 2012

Powershell: Adding users to active directory with a csv


Creating users in AD from a csv file using Powershell

Using Import-Csv and New-ADUser

Some examples in the links
this is good:
http://gallery.technet.microsoft.com/scriptcenter/ed20b349-9758-4c70-adc0-19c5acfcae45
better than this:
http://social.technet.microsoft.com/Forums/en-US/winserverDS/thread/374dca0b-6b93-4a77-b53b-51602b2b4544/

And worth a look? simple automation straight from a csv, and  adding to a group also
http://www.simple-talk.com/sysadmin/exchange/active-directory-management-with-powershell-in-windows-server-2008-r2/

Having problems with execution? see:
http://technet.microsoft.com/en-us/library/ee176949.aspx

Import-Module ActiveDirectory
$Users = Import-Csv ".\myusers.csv" 
foreach ($User in $Users) 

    $OU = "OU=MyUsers,OU=MyStuff,DC=mydomain,DC=local,DC=com"
    $Detailedname = $User.firstname + " " + $User.lastname
    $Firstname = $User.Firstname
    $FirstLetterFirstname = $Firstname.substring(0,1) #not used this but left it in
    $SAM =  $User.Firstname.tolower() + "." + $user.lastname.tolower()
    $userprinci = $SAM + "@mydomain.local.com"
    $logonscript = "logscript.vbs"
    $homedir = "\\server\myarea\" + $SAM + "\My Documents"
    #tried this alternative
    #$homedir = "\\server\myarea\%username%\My Documents"
    New-ADUser -Name $Detailedname -SamAccountName $SAM -UserPrincipalName $userprinci -DisplayName $Detailedname -GivenName
$user.firstname -Surname $user.lastname -Path $OU -HomeDrive "H:" -HomeDirectory $homedir -scriptpath  $logonscript    -
PasswordNeverExpires $True -PassThru
#the password is blank on this example
}



Still issue with creating home directory for user, seems that i have to create this after by using the %username%, then apply this, then add My Documents.

I dont know if this is due to the user not being in a group(i.e. with correct privileges) or what. But cannot have the user in a group till user exists anyway!!??

So therefore I also needed to manually add to group.

This is the part mentioned earlier that adds users to groups, a bit pointless for now
add users to group"OU=MyUsers,OU=MyStuff,DC=mydomain,DC=local,DC=com"  |  ForEach-Object {Add-ADGroupMember -Identity 'ggGroupName' -Members $_}



Thursday 20 September 2012

Twitter widget customization

http://www.1stwebdesigner.com/css/customize-twitter-search-widgets/

Twitter widget customization, after copying the code from a currently embedded widget like the one on here ;)

Tuesday 18 September 2012

Awk, Sed and TR

I used Awk, but had issues with removing whitespace and inserting commas.

I had a poorly written Awk text file script, that filled out 19 fields with info. Done in thee style of a none-programmer.

{ FS = "," } ; # comma-delimited fields
{ sub($1,"")}
{firstname=$3}
{surname = $4}
{group = $8}
{username =tolower( $3"."$4)}
.....
#more fields here zzzzzzzzz
.....
{$16=" "}
{$17=" "}
{$18=" "}
{$19=" "}
{print}

which was invoked like this:

awk -f mybadscript.awk mydata.csv > newdata.csv

Then I had to run Sed

sed 's/[:space:]+/,/g' newdata.csv > afterseddata.csv
http://stackoverflow.com/questions/8766165/using-awk-to-remove-whitespace

Then ran TR

tr ' ' ',' < afterseddata.csv > aftertrdata.csv
http://stackoverflow.com/questions/1271222/replace-white-spaces-with-a-comma-in-a-txt-file-in-linux

Phew. Perl might be easier next time.


Monday 17 September 2012

Awk substitute and concatenate columns

Using Awk


awk -F, '{ sub($1,"");temp = $3"."$4; $2 = temp; print}' myfile.csv

set delimiter as comma, then removes column 1 sub from "", takes column 3 and 4 and concatenates with a full stop in between them, and puts that in column 2


This was used so i could take a name in a file with a first and last name and create a username like joe.bloggs


Another useful Awk feature is sub strings


awk -F, '{ sub($1,"");temp = $3"."$4; $2 = temp; first= substr($3,1,1); second = substr($4,1,1); $5=first second  ; print}' myfile.csv

substr($3,1,1) takes first char of column 3 puts it in variable first
substr($4,1,1) takes first char of column 4 puts it in variable second
$5 = first second prints these 2 chars together, no spaces

Use on Joe Bloggs to create new column  with contents - JB


This used the substr function

Every good boy.

awk '{print substr($1,1,1)}' temp returns E
awk '{print substr($1,3)}' temp returns ery
awk '{print substr($2,3)}' temp returns od
awk '{print substr($0,7,2)}' temp returns go
 
 






Friday 31 August 2012

mysql joins

a mysql join

ties 2 tables.

shows all of stockbook, and using a non-descriptive index within stockbook table i.e a number, it displays the more descriptive column from the other table

This works even if the relationship is not enabled, but enabling the relationship prevents incorrect entries by forcing integrity with the drop down list

SELECT `stockbook`.*, `categories`.`type`
FROM stockbook, categories WHERE `stockbook`.`categories` = `categories`.`category_id`

example from

http://www.tizag.com/mysqlTutorial/mysqljoins.php

and statement and ordering with AS command for column ambiguity resolution

SELECT `stockbook`.*, `categories`.`type`,`locations`.`notes` AS 'Location Notes'
FROM stockbook, categories,locations WHERE `stockbook`.`categories` =  `categories`.`category_id` && `stockbook`.`location` = `locations`.`location_id` ORDER BY `stockbook`.`product_id`

Mysql phpmyadmin search replace

phpmyadmin syntax, note no speech marks on tablename or field name

UPDATE tablename SET field = REPLACE ( 
field, 
'HLLOWRDCHG', 
'HELLOWORLDCHANGE');

Tuesday 28 August 2012

VI editor tricks

Word count


http://vim.wikia.com/wiki/Word_count

find text, then replace part of text

There is another form of line addressing called global addressing. It is similar to the % (all lines) address, but allows you to limit the search and replace action by specifying certain text that must appear in a line before the search and replace action is applied to it. An example is show below. The syntax shown below would read "for all lines containing `some text', search for `search text' and replace any instances with `replacement text.'"

:g/some text/s/search text/replacement text/

other stuff


:%s/test/mytest/gIc

arguments g=global, I=dont ignore case, c=confirmation required

regex

:%s/[A-Z]', '2'//gn

count occurences of: letter then comma then space then apostrophe then 2 apostrophe


Thursday 7 June 2012

Interesting Language

http://cultureofsoccer.com/2007/06/19/the-sapir-whorf-hypothesis-and-how-language-affects-our-understanding-of-soccer/

In the Japanese language, for example, the word for self is jibun. This word is made up of two parts, ji, which means part, and bun, which means group. Put together, jibun, the Japanese word for self, literally means part of a group.
This may seem like mere semantical nitpicking until one also considers the way Japanese people typically conceive of the self. Unlike Western culture, which is more inclined to view an individual on his or her own, Japanese culture views people always within the context of a group. (For further reading on this topic, I recommend Japanese psychoanalyst Takeo Doi’s book The Anatomy of Dependence.)

Thursday 26 April 2012

Installing Sophos endpoint on Windows 7

Issue installing sophos on windows 7 pc, made sure the remote registry service was running, looked round sophos site, but so many misleading answers, finally found this,which mentions file sharing within the windows firewall settings:

http://www.reading.ac.uk/internal/its/help/its-help-pcsecurity/its-sophos-troubleshoot.aspx

section: Updating Has Never Worked Since Installing

Slightly different for me, I typed 'firewall' in search/run bar on start menu. Selected 'Windows Firewall', (not advanced security).

On left selected 'Allow program or feature through windows firewall'

Ticked 'File and printer sharing'
Works now!

P.S
Had another issue after upgrading endpoint to 5.2
Excerpt from: http://downloads.sophos.com/tools/on-line/deployment_guide/en-us/index.html
(on right hand side Enterprise console 5.2)

'Overview of required settings
The table below gives an overview of all the settings required to protect and manage an endpoint computer. If you are familiar with creating and configuring Group Policy Objects (GPOs) you can use the table below to quickly configure your network. If not, follow the detailed instructions below the table.
Requirement Details
Windows Firewall Rules
 File and Printer Sharing (SMB-In)
Remote Scheduled Tasks Management (RPC)
Sophos Remote Management (TCP 8192 and 8194 Inbound and Outbound)

Services Task Scheduler (Started)
Windows Installer (not Disabled) '

For me the Windows Installer service needed to be started! It was not disabled, it was just set to manual and in stopped state.

Tuesday 3 April 2012

IIS 7 FTP firewall woes sorted

Note:- First I was following this:
http://learn.iis.net/page.aspx/301/creating-a-new-ftp-site-in-iis-7/

which is similar if not the same to the preceding chapters of the article linked below.

but i did find there was an issue and it was helpful to use this info: http://forums.iis.net/t/1161450.aspx
[quote]D'oh. Instead of setting up a binding to 127.0.0.1 i set up a binding to ::1 and it immediately started working. In the tutorial 127.0.0.1 seemed to work, so i'm not sure whether the tutorial is wrong or it's just a simple setting somewhere. Anyways it's working fine now. [/quote]  

'All Unassigned' worked also for me   

Bindings found by right clicking   Ftp Site -> Edit Bindings  

anyway... back to it...
     

Using Windows Firewall with non-secure FTP traffic

From Article:
http://learn.iis.net/page.aspx/309/configuring-ftp-firewall-settings-in-iis-7/


To configure Windows Firewall to allow non-secure FTP traffic, use the following steps:

  1. Open a command prompt: click Start, then All Programs, then Accessories, then Command Prompt.
  2. To open port 21 on the firewall, type the following syntax then hit enter:
    netsh advfirewall firewall add rule name="FTP (non-SSL)" action=allow protocol=TCP dir=in localport=21
  3. To enable stateful FTP filtering that will dynamically open ports for data connections, type the following syntax then hit enter:
    netsh advfirewall set global StatefulFtp enable

Important Notes:

  • Active FTP connections would not necessarily covered by the above rules; an outbound connection from port 20 would also need to be enabled on server. In addition, the FTP client machine would need to have its own firewall exceptions setup for inbound traffic.
  • FTP over SSL (FTPS) will not be covered by these rules; the SSL negotiation will most likely fail because the Windows Firewall filter for stateful FTP inspection will not be able to parse encrypted data. (Some 3rd-party firewall filters recognize the beginning of SSL negotiation, e.g. AUTH SSL or AUTH TLS commands, and return an error to prevent SSL negotiation from starting.)

Using Windows Firewall with secure FTP over SSL (FTPS) traffic


The stateful FTP packet inspection in Windows Firewall will most likely prevent SSL from working because Windows Firewall filter for stateful FTP inspection will not be able to parse the encrypted traffic that would establish the data connection. Because of this behavior, you will need to configure your Windows Firewall settings for FTP differently if you intend to use FTP over SSL (FTPS). The easiest way to configure Windows Firewall to allow FTPS traffic is to list the FTP service on the inbound exception list. The full service name is the "Microsoft FTP Service", and the short service name is "ftpsvc". (The FTP service is hosted in a generic service process host (Svchost.exe) so it is not possible to put it on the exception list though a program exception.)

To configure Windows Firewall to allow secure FTP over SSL (FTPS) traffic, use the following steps:

  1. Open a command prompt: click Start, then All Programs, then Accessories, then Command Prompt.
  2. To configure the firewall to allow the FTP service to listen on all ports that it opens, type the following syntax then hit enter:
    netsh advfirewall firewall add rule name="FTP for IIS7" service=ftpsvc action=allow protocol=TCP dir=in
  3. To disable stateful FTP filtering so that Windows Firewall will not block FTP traffic, type the following syntax then hit enter:
    netsh advfirewall set global StatefulFtp disable

Thursday 22 March 2012

windows 7: Load a network driver in repair mode

http://support.microsoft.com/kb/923834

Manually load the network driver, and then verify that it is the correct driver. To do this, follow these steps:
  1. At a command prompt, type the following command, and then press ENTER:
    drvload driver.inf
    Notes
    • Driver.inf is the name of the third-party network driver.
    • You have to specify the full path and the name of the driver. For example, if Driver.inf is on a CD, and the CD drive is drive D, type the following command, and then press ENTER:
      drvload.exe d:\Folder\Driver.inf
  2. Type wpeutil InitializeNetwork, and then press ENTER.
  3. To verify network connectivity, type ipconfig /all.

    Note The ipconfig /all command generates a detailed configuration report for all interfaces that include any remote access adapters.

Wednesday 21 March 2012

Windows disk partition from command line

Windows disk partition from command line

Type: diskpart
and press Enter

Type: select disk 0 (zero)
and press Enter

type: list volume
and press Enter