$DateString = (Get-Date).AddMinutes(-30).ToString("u") -Replace "-|:|\s"
$DateString = $DateString -Replace "Z", ".0Z"
write-host "(&(sAMAccountType=805306368)(whenCreated>=$DateString))"
8 jan 2014
9 sep 2013
create shortcut with powershell
function Set-Shortcut ($linkpath , $targetPath )
{
Write-Host $linkpath
$strlinkpath = [String ]$linkpath
if($targetPath -eq -$NULL)
{
throw ("targetpath not available" )
}
else
{
if(Test-Path $targetPath)
{
}
else
{
throw " $targetPath does not exist"
}
}
if($strlinkpath -eq $NULL)
{
throw “linkpath not correct”
}
elseif($strlinkpath .EndsWith(".lnk" ))
{
$link = ( New-Object -ComObject WScript.Shell). CreateShortcut($strlinkpath)
$link.TargetPath = $targetPath
## Added after grawity's post
$link.Save()
}
else
{
throw ("filename not available in path" )
}
}
11 mrt 2013
script to generate files in folder structure
$DefaultPath = "
$dirs = get-childitem -Recurse -Path $DefaultPath | where {$_.mode -match "d"}
foreach($dir in $dirs)
{
$dirname = $dir.FullName
for ($i=1; $i -le 100; $i++)
{
$filename = "$dirname\file$i.txt"
write-host $filename
New-Item $filename -type file -force -value "This is text added to the file"
}
}
30 sep 2012
Reading and writing to GPX Files
public static void CreateNewGpxFile()
{
gpxType Gpxfile = new gpxType();
trkType Tracking1 = new trkType();
trksegType TrackingRegister = new trksegType();
wptType Waypoint1 = new wptType();
Waypoint1.lon = ( decimal) 4.13;
Waypoint1.lat = ( decimal) 51.7;
wptType Waypoint2 = new wptType();
Waypoint1.lon = ( decimal)4.18;
Waypoint1.lat = ( decimal)51.6;
List<wptType > Waypoints = new List<wptType >();
Waypoints.Add(Waypoint1);
Waypoints.Add(Waypoint2);
TrackingRegister.trkpt = Waypoints.ToArray();
Tracking1.trkseg = TrackingRegister.SingleItemAsArray< trksegType>();
Gpxfile.trk = Tracking1.SingleItemAsArray< trkType>();
string Gpxfilestring = FileToStringBuilder(@"c:\temp\test.gpx" ).ToString();
Gpxfile = DeserializeFromXml<gpxType>(Gpxfilestring);
}
|
1. Go to http://www.topografix.com/GPX/1/1/gpx.xsd and dowload the xsd schema to C:\temp\ of your computer.
2. Start the Visual Studio 2010 CMD
3. execute the command : xsd c:\temp\gpx.xsd /classes /out:c:\temp\
25 sep 2012
excel is very slow
- be sure there are no conditional formatting rules
- be sure that the excel file does have links to websites / server that aren't accessible at this moment.
- be sure that the images are small (compress all pictures in the excel)
- be sure that the excel file does have links to websites / server that aren't accessible at this moment.
- be sure that the images are small (compress all pictures in the excel)
Get logged on users
ever tryed to resolve the logged onusers with wmi?
I think it is just the wrong way.
public static List< string> GetLoggedOnUsers(string Computername)
{
List<string > Users = new List<string >();
try
{
// Open HKEY_USERS
// on a remote computer.
RegistryKey environmentKey = RegistryKey.OpenRemoteBaseKey(RegistryHive .Users, Computername);
foreach (string subKeyName in environmentKey.GetSubKeyNames())
{
RegistryKey rkeyuser = environmentKey.OpenSubKey(subKeyName);
RegistryKey rkeyVendor = rkeyuser.OpenSubKey("Volatile Environment");
if (rkeyVendor != null )
{
String[] ValueNames = rkeyVendor.GetValueNames();
foreach (string name in ValueNames)
{
if(name=="USERNAME" )
Users.Add(rkeyVendor.GetValue(name).ToString());
}
}
}
// Close the registry key.
environmentKey.Close();
}
catch
{
}
return Users;
}
11 sep 2012
parse xml to vcard.xsl
vcard.xml
xml version =" 1.0 " ?>
xml-stylesheet href="vcard.xsl" type="text/xsl" ?>
<contacts>
<Contact>
<FullName> John </FullName >
<LastName> Johnson </LastName >
<FirstName> John </FirstName >
<MiddleInitial></ MiddleInitial >
<Title></ Title >
<Suffix></ Suffix >
<OfficeStreetAddress></ OfficeStreetAddress >
<OfficeCity></ OfficeCity >
<CellPhoneNumber> +123456789 </CellPhoneNumber >
</Contact>
</contacts>
|
vcard.xsl
xml version =" 1.0 " encoding =" UTF-8 "?>
< xsl:stylesheet
version =" 1.0 "
xmlns:xsl =" http://www.w3.org/1999/XSL/Transform "
xmlns =" http://www.w3.org/1999/xhtml ">
< xsl:output method = "text " indent = "yes " />
< xsl:template match =" Contact ">
BEGIN:VCARD
VERSION:3.0
FN;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8: < xsl:value-of select =" FullName "/>
N;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8: < xsl:value-of select =" LastName "/> ; <xsl:value-of select= " FirstName" /> ;< xsl:value-of select =" MiddleInitial "/> ; <xsl:value-of select= " Title" /> ;< xsl:value-of select =" Suffix "/>
ADR;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8;TYPE=WORK;TYPE=PREF:;; < xsl:value-of select =" OfficeStreetAddress "/> ; <xsl:value-of select= " OfficeCity" /> ;< xsl:value-of select =" OfficeState "/> ; <xsl:value-of select= " OfficeZIP" /> ;< xsl:value-of select =" OfficeCountry "/>
ADR;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8;TYPE=HOME;TYPE=PREF: < xsl:value-of select =" PostOfficeAddress "/> ;; <xsl:value-of select= " StreetAddress" /> ;< xsl:value-of select =" City "/> ; <xsl:value-of select= " State" />< xsl:value-of select =" County "/> ; <xsl:value-of select= " Zip" /> ;< xsl:value-of select = "Country " />
TITLE;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8: < xsl:value-of select =" JobTitle "/>
ORG;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8: < xsl:value-of select =" CompanyName "/> ; <xsl:value-of select= " Department" />
EMAIL;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8;TYPE=INTERNET: < xsl:value-of select =" InternetAddress "/>
TEL;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8;TYPE=CELL: < xsl:value-of select =" CellPhoneNumber "/>
TEL;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8;TYPE=HOME: < xsl:value-of select =" PhoneNumber "/>
TEL;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8;TYPE=WORK: < xsl:value-of select =" OfficePhoneNumber "/>
URL;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8: < xsl:value-of select =" WebSite "/>
X-IBM-LOOKUP-TYPE: <xsl:value-of select= " Type" />
END:VCARD
</ xsl:template>
</ xsl:stylesheet>
|
Sources :
Abonneren op:
Posts (Atom)