How to check powershell errors when running powershell from task scheduler

You can use the following method.

Add this to your powershell script in various places

“Start!” | Out-File c:\mylog.txt

then use try/catch method to catch the errors

#Get data from database and export to file
try{

“SQL Starts” | Out-File c:\mylog.txt

YOUR CODE HERE
} catch [Exception]
{
“Error: {0}” -f $_.Exception.Message | Out-File c:\mylog.txt
$error | Out-File c:\mylog.txt
}

“End” | Out-File c:\mylog.txt

then check your error log file for issue.

 

It happens that the script wasn’t always working and after getting it sorted I have found this

Error: The term ‘Invoke-SqlCmd’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Invoke-SqlCmd : The term ‘Invoke-SqlCmd’ is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is

To fix the problem i had to add the following to the begining of the script

# Import the SQL Server Module.
Import-Module Sqlps -DisableNameChecking;

This has fixed the problem.

 

 

 

 

 

 

 

How to redirect root directory in IIS to something else

Open up IIS install Rewrite module

https://www.iis.net/downloads/microsoft/url-rewrite

then navigate to roo

Your site-> URL Rewrite -> Add new Inboud Blank Rule (This ideally should be first in the top level) then

Requested URL -> Matches the Patter

Using -> Regular Expression

Patter -> ^$

Action -> Action Type – > Redirect
Redirect URL -> Your Site to which you want redirect the root (This can be a sub folder)

Redirect Type (301) Permanent this means that the browser will keep the info and will no need to make a request next time to your server.

Tick  – Stop process other rules.

Enjoy!

 

 

IPHONE 7 Best Black Friday Deal £25.99

ENTER: BLACKNOV32 to get £100 off

http://www.mobiles.co.uk/apple-iphone-7-32gb-rose-gold.html?tid=EF5QMAUG16&affiliate=awinm-103504&awc=380_1479397393_8a8e244caf2f85401ce8be255dbe4ed0&utm_source=Awin&utm_medium=Affiliate&utm_campaign=TechRadar

 

£225.00 handset cost

  • Unlimited mins
  • 2GB data
  • Unlimited texts
Only

£25.99

Per month / 24 month

Voucher -£100.00
= Save-£100.00

  Total
= £25.99 per month
To pay today Total
= £ 125.00

 

How to restore Cisco IOS config from backup using console

  1. Install the TeraTerm -> Start and use COM port to connect to console

You console configuration might be as follow

COM1

Speed 9600

Data Bits 8

Stop Bits 1

Parity None

Flow Control None

2. Connect to switch/switch using console

enable

copy xmodem: run (This will copy the config to running config)

Once the transfer is started navigate in Teraterm to

File -> Transfer -> XMODEM -> Send… then select the file.

you can then run

show running-config

and you configuration should be there.

 

 

How to rename file in Cisco Flash IOS

If you have need to rename any file in the Cisco flash then you can use the following

dir – to display list of files in flash

then

2  -rwx     8055040   Mar 1 1993 14:24:51 +00:00  c2960-lanbasek9-mz.122-50.SE1.bing

then type

rename flash:c2960-lanbasek9-mz.122-50.SE1.bing c2960-lanbasek9-mz.122-50.SE1.bin

then confirm destination file

Destination filename [c2960-lanbasek9-mz.122-50.SE1.bin]?

once done .

dir

2  -rwx     8055040   Mar 1 1993 14:24:51 +00:00  c2960-lanbasek9-mz.122-50.SE1.bin

We can see that the file has been renamed correctly.