Tuesday, 14 October 2014

Elevated command prompt tip

Enter the word "command" in the search bar, instead or pressing enter press "Ctrl - Shift - Enter", this brings up UAC and asks for an admin password.

I used this in my other post:
http://asdirkseesit.blogspot.co.uk/2013/06/how-to-view-group-policy-preferences-on.html
(see addendum section)

Mentioned here

http://www.howtogeek.com/howto/windows-vista/run-a-command-as-administrator-from-the-windows-vista-run-box/



Wednesday, 9 July 2014

Advanced XML filtering windows event viewer

Nice link here:

http://blogs.technet.com/b/askds/archive/2011/09/26/advanced-xml-filtering-in-the-windows-event-viewer.aspx

Contains stuff that helps narrow down event filtering on win server

      <QueryList>
           <Query Id="0">
              <Select Path="Security">
                 *[EventData[Data[@Name='SubjectUserName'] and (Data='test9')]]
               </Select>
           </Query>
      </QueryList>


Much better than usual limiting filters

Tuesday, 8 July 2014

Network issues and ping returns strange characters

Had some issues with computer not working correctly on the network. Could not ping NetBIOS name, so presumed it was a DNS issue.

Then whilst pinging ip address I noticed weird ascii characters were returned
http://www.pcreview.co.uk/forums/strange-characters-ping-results-t248058.html

I was led to doing another "netsh winsock reset catalog" command and this resolved it.


Friday, 13 June 2014

Avrdude atmel studio integration

These are notes for using Avrdude with Atmel Studio. They need more context just like the links provide.

I will add more detail hopefully soon, just in case the links go dead.

Watch for "  the inverted commas, I had some issue with these.

Guide:
  1. Select Tools > External Tools
  2. Then fill the details in window as show in the screenshot




########### Workings out for setting avrdude in Atmel Studio ####
for use with assembler uploading hex file
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=1158681
http://asensar.com/2013/06/23/programming-arduino-using-avrdude/
http://asensar.com/2013/06/23/how-to-integrate-avrdude-with-atmel-studio/


### initial output from Arduino

Binary sketch size: 1,084 bytes (of a 32,256 byte maximum)
\\path\Arduino
\hardware/tools/avr/bin/avrdude -C\\path
\Arduino\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P\
\.\COM6 -b115200 -D -Uflash:w:C:\Users\user\AppData\Local\Temp
\build4700042702866457239.tmp\Blink.cpp.hex:i


## simplifying the above output

avrdude -C\\path\Arduino
\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P\\.\COM6
-b115200 -D -Uflash:w:<myhexfile>:i

uno.name=Arduino Uno
uno.upload.protocol=arduino
uno.upload.maximum_size=32256
uno.upload.speed=115200
uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
uno.bootloader.path=optiboot
uno.bootloader.file=optiboot_atmega328.hex
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.core=arduino
uno.build.variant=standard

## copy of other chaps. needed tweaking. paths etc

-F -v -patmega328p -carduino -P.COM6 -b115200 -D -Uflash:w:"$(ProjectDir)Debug\
$(ItemFileName).hex":i -C\\path\Arduino
\hardware/tools/avr/etc/avrdude.conf

Wednesday, 15 January 2014

Append a Location to the Path Environment Variable using vbscript

http://blogs.technet.com/b/heyscriptingguy/archive/2006/08/28/how-can-i-append-a-location-to-the-path-environment-variable.aspx


strComputer = "." <----- or changes this "." to computer name e.g. "computer-01"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From Win32_Environment Where Name = 'Path'")

For Each objItem in colItems
    strPath = objItem.VariableValue & ";C:\Scripts\"
    objItem.VariableValue = strPath
    objItem.Put_
Next

Tuesday, 25 June 2013

re-install a package installed by group policy

Seems I cannot reinstall a program using group policy when the program has been originally rolled out by group policy, even when it has been uninstalled on the machine by an admin user

see here

http://www.frickelsoft.net/blog/?p=103

seems I must delete registry key to allow for the package to be reinstalled via group policy

Simply delete corresponding key from:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\AppMgmt

NOTE: Don't delete the actual AppMgmt key, explode the key to see the GUIDs, if you click on one it will then give you the details so you can ascertain which GUID relates to which software. Then delete the whole key relevant.

And another example here http://www.mysysadmintips.com/windows/active-directory/210-force-applications-to-be-re-installed-by-group-policy

Copy file to multiple PCs with group policy

I used this example:
http://www.silentcrash.com/2012/06/copy-files-multiple-computers-group-policy-gpo/

main thing being that the file needed to be a .cmd extension

I also changed the switch to overwrite current file without prompting
Xcopy \\server\netlogon\scratch.ini "C:\Program Files\Scratch\" /Y

I used netlogon but not sure its needed, had a few issues trying to use a .vbs file initially.

Monday, 17 June 2013

how to view group policy preferences on local machine - rsop.msc

I was wondering what to use to view settings applied in the group policy preferences section of group policy. I liked rsop.msc :-(

The preferences section is not on show.

I read some stuff here : rsop.msc and gpresult not including preferences

I briefly tried GPRESULT /H rsop.html (if ran from run command the output of this seemed to go to my users root e.g. c:\users\username) but still didn't see the group policy preferences section (which is under Computer) displayed.

Then elevated rights worked, see here: http://answers.microsoft.com/en-us/windows/forum/windows_7-networking/why-doesnt-gpresult-r-display-computer-settings/597f945c-1be4-4af5-9bed-622e54c82b1e

Therefore open a cmd prompt to run, "GPRESULT /H rsop.html" and change to suitable file path for generated output

The Computer section of group policy needed administrative rights to display.

Addendum

I adding another point to this post so its all together.

Regarding running rsop.msc as a restricted user and being unable to view 'Computer' policies due to being a restricted user.

I would like to right click command prompt and run as an elevated user, but the right click context menu is disabled....errr...

A workaround for this is to use type command into search box and instead of clicking enter click Ctrl+Shift + Enter this brings up the UAC asking for admin login.

I can then navigate to a user folder, as I cannot seem to change drives??? Run "GPRESULT /H rsop.html", then run rsop.html all from command prompt. This fires up the browser with my results.

All stated here: http://www.howtogeek.com/howto/windows-vista/run-a-command-as-administrator-from-the-windows-vista-run-box/



Thursday, 6 June 2013

IE 10 proxy settings group policy not being applied

Same as this issue: http://www.edugeek.net/forums/windows-8/114433-ie-proxy-windows-8-server-2008r2.html#post979207

Had to start using Group Policy Preferences , the bottom part of group policy editor 'user configuration->preferences->control panel settings->internet settings'


I tried this and it worked:

I searched google and used this extra info:
http://social.technet.microsoft.com/Forums/en-US/winserverGP/thread/58939ec8-1396-453e-af54-f03603e10723

the post timestamped Wednesday, April 17, 2013 4:57 PM by Babylon78.

This is what I did:
Open up the policy, and create an IE8 Preference: User Configuration --> Preferences --> Control Panel Settings --> Internet Settings --> New --> Internet Explorer 8.
Set my proxy settings.

Navigate to C:\Windows\SYSVOL\domain\Policies was an easier route, then sort by date for the recently created IE entry.
Navigate to User\Preferences\InternetSettings 
"Open up the "InternetSettings.xml" file, and change the MAX value to something above 10.0.0.0 (I usually put 10.5.0.0). This way, the policy won't trip up later on if IE 11 comes out and doesn't support any of these policies, but at least you'll be safe until 10.5.0, or until a hotfix is available. " -babylon78

max="10.5.0.0"

Tuesday, 21 May 2013

User not receiving proxy settings. precedence disabled win 7

This issue seems to suggest that the precedence of GPO rules is at fault, that some entry is overriding something else, but this is not the case I do not think. After reading a million nonsensical posts by microsoft pros i end up none the wiser.

I eventually opt to delete the locally cached profile for the user, and its solves the issue.

On the affected machine, right click my computer-> properties,->advanced system settings->user profiles

Tuesday, 15 January 2013

IE certificate . Continue to this website. Not working


Internet Explorer Certificate Security Warning, cannot continue (blocked)

But even if we click on "Continue to this website (not recommended).", nothing happens. totally blocked!

Because of the latest updates : KB2661254

IE prevents  connection to any website that use a certificate with less than 1024 bits key

To fix it, you can add a dword key in the registry :

HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\OID\EncodingType 0\CertDLLCreateCertificateChainEngine\Config\
DWORD (32 bit) : MinRsaPubKeyBitLength
value : 512 (decimal)

Thanks: berneyi  of experts exchange

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.)