This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//uses LINQPad | |
void Main() | |
{ | |
List<dimDate> dimDates = genDimDate( | |
DateTime.Parse("1/1/2012") | |
, DateTime.Parse("12/31/2017") | |
); | |
dimDates.Dump(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
string sPath = @"c:\temp\somedoc.docx"; | |
ShowFields(sPath); | |
} | |
//using Microsoft.Office.Interop.Word | |
void ShowFields(string sPath) | |
{ | |
//references for the com objects | |
Application oApp = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first, download image to somewhere | |
# make a note of the location | |
# i am going to use: | |
# ~/Downloads/2017-04-10-raspbian-jessie-lite.img | |
read -n 1 -s -p "Download the image and press any key to continue..." | |
# i sudo bash first | |
sudo bash | |
# let's get the current disks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#plaintext password | |
$pt= "P@ssword1" | |
$pt | |
#convert to secure string object | |
$oss= $pt | ConvertTo-SecureString -AsPlainText -Force | |
$oss | |
#secure string object as a string, this is what you store in a file | |
$sss= $oss| ConvertFrom-SecureString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#get local accounts from a list of servers | |
# get the list, make sure the servers pass a ping check, pull back the account list | |
# ignore the errors, we only care about the stuff we *can* reach | |
# uses servers.csv file with a Name column as input | |
# outputs to accounts.csv | |
$servers = $null # server list, pulled name and sorted from csv | |
$pj = $null # ping job | |
$pr = $null # ping results | |
$upservers = $null #servers who were pinged successfully |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Import CSV, dynamically generate column names | |
Import-Csv -Header (00..( (gc file.csv)[0].split(",").Count-1 )|%{"c{0}" -f $_}) -Path file.csv | |
#ternary | |
@('false','true')[$true] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Send me an email | |
Send-MailMessage ` | |
-From "name <[email protected]>" ` | |
-To @("me <[email protected]>") ` | |
-Attachments $fi.FullName ` | |
-SmtpServer "10.10.10.10" ` | |
-Port 25 ` | |
-Subject "Subject" ` | |
-Body "PFA File: $($fi.Name)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Inventory a list of machines: | |
"server1","server2" | % { | |
$c = $_ #var to hold computer name | |
$o = @() #hashtable to hold results | |
$o += Get-WmiObject -ComputerName $c -Class Win32_OperatingSystem | |
$o += Get-WmiObject -ComputerName $c -Class Win32_BIOS | |
$o += Get-WmiObject -ComputerName $c -Class Win32_ComputerSystem | |
$o += Get-WmiObject -ComputerName $c -Class Win32_Processor | |
$o += Get-WmiObject -ComputerName $c -Class Win32_LogicalDisk | Where-Object {$_.DriveType -eq 3} | |
$o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find users by properties: | |
Get-ADUser -f {name -like '*ashbrook*'} | |
Get-ADUser -f {givenname -like '*roy*'} | |
Get-ADUser -f {surname -like '*ashbrook*'} | |
Get-ADUser -f {mail -eq '[email protected]'} | |
Get-ADUser -Filter {surname -eq "ashbrook"} | measure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Reset User Password: | |
function Set-Pass { | |
Param ($Identity, $PlainTextPassword) | |
$a = $Identity | |
$b = $PlainTextPassword | |
$c = ConvertTo-SecureString -AsPlainText $b -Force | |
$d = Set-ADAccountPassword $a -Reset -NewPassword $c | |
} |
OlderNewer