techjunkie.tv

powershell tips, ccna tips, tech videos, learn tech

How do you create a message Box with powershell? —

Hello Everyone here is a another Windows Powershell tip that I use everyday, I use this to notify me of a backup I run so that I know it completed. Here is the code

[system.Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”);[Windows.Forms.MessageBox]::Show(“The UAS was backedup at $(get-date)”, “UAS Nightly Backup”, [Windows.Forms.MessageBoxButtons]::OK, [Windows.Forms.MessageBoxIcon]::Information)

What do you think?


How Can I backup my quicken data files with Powershell? —

The other day i was asked how do I backup my quicken data files but I want it to be seemless and automatic without me knowing, maybe it can send me an email to let me know that the backup went through.

This is very simple for My favorite Scripting Language MS Powershell

I started looking for the Quicken Data directory that contains the Quicken data files.

Then I made a folder for the backups to be put in on a weekly basis or daily depending on the customer choice

After I finish this script maybe I can have it send the user a email with a copy and paste from one of thse scripts on www.techjunkie.tv

here is the code to what i have so far

$date = get-date -uformat “%Y-%m-%d_%H%M”

$backuppath = “F:\Quicken_Backups”

$Month = (get-date).AddMonths(-15)

$Path = “G:\!scott_data\qk_data\quicken_data_fromdisk”

If (Test-Path -Path $Path) {
Cp $path -Destination $backuppath”\”$date -Recurse
echo “backup Completed!!!”
}
$Container = ls $backuppath | ? {$_.psiscontainer}

ForEach ($file in $Container) {
IF ($file.LastAccessTime -lt $month) {
del -Path $file.fullname -recurse -whatif
}
}

Let me know what you think guys

and as always please@!!! leave me a comment if u use this on your own Quicken 2005 to automaticly backitup


Connect to Sybase Using PowerShell —

I have a new Sybase database server that I have to start backing up.

Since I have been using Powershell for all my Automatic tasks like Backing up and Excel Reports and emails to notify me of different issues I decided to make Powershell my default way of backing up the Sybase Server the same way I do my MS Sql Servers. Here is the code.

$query=”select * from ROCTbl”
$conn=New-Object System.Data.Odbc.OdbcConnection
$conn.ConnectionString= “driver={Adaptive Server Enterprise}; dsn=odbcname;db=dbname;na=10.128.2.69,6969;uid=UserName;pwd=password;”
$conn.open()
$cmd=new-object System.Data.Odbc.OdbcCommand($query,$conn)
$cmd.CommandTimeout=30
$ds=New-Object system.Data.DataSet
$da=New-Object system.Data.odbc.odbcDataAdapter($cmd)
$da.fill($ds)
$ds.Tables[0] | out-gridview
$conn.close()

I was able to do this with the help from this post from merlinthemouse

LEt me know what you think because I am thinking of using Sybases OLEDB option just in case it is faster. LEt me know what you think by leaving me a comment.


How to change rows to columns in excel or How to change Columns into rows —

In the morning to all you Techjunkies out there. I ran into an issue at work today as I was creating a bunch of excel sheets for my boss. The issue I was running into was that as I was entering columns into Excel. I started noticing I had to scroll all the way to the right side of the sheet and then scroll back to the left side and back and fourth. Well I thought if the row of data was going down then all would be better because of not having to lose the data on the screen and scrolling back and fourth. I asked myself, “How do I change a row of data into columns of data?” This is such a great solution because your using Excels Logic to do the conversion instead of having to cut/copy and paste 50 times if you know what I mean.

Here is the link to how to change rows to columns in excel

Let me know if this was helpful to you by leaving a comment or send me a email.

Thanks

Scottalvarino