Category: powershell

Powershell vs console application

I have decided to make the utilities that I use in form of Powershell applications instead of Windows / Console applications

Pros:

There are simpler to use  – just run the powershell

The parsing of command line is powerfull in powershell

There are simpler to maintain ( just text scripts files)

There are no big dependencies( .NET Core/ .NET 4.x  to be installed)

This is a good tool under  my toolbelt

Everything you do in .NET you can do in Powershell ( sometimes it is much harder in .NET rather then powershell)

 

The repository is https://github.com/ignatandrei/PowershellUtils and the first item is to move the big files from C: into another drive to free space by making a junction dir ( e.g. C:\ProgramData\Package Cache and C:\Windows\Installer )

WifiHotSpot

 

I have become tired of reading about how to enable Wifi HotSpot in Windows 10 . The reference is here: https://msdn.microsoft.com/en-us/library/windows/desktop/dd815243%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 . ( also, for bandwidth throttling you can try  https://github.com/jagt/clumsy and / or https://reqrypt.org/windivert.html   )

I was trying to make a Windows Store application – but, apparently, it is very difficult to run command lines application from Windows Store/

So I made a small powershell file ( hosted at https://github.com/ignatandrei/WIFIHotSpot )

Enjoy!

Powershell and always use explicit

 

Let’s suppose you have a variable $x=”http://msprogrammer.serviciipeweb.ro/

In powershell the following are the same

$x

Write-Host $x

 

I want to make a function that returns a value . Let’s say

Function Add([string] $a, [string]$b)

{

#debug to see arguments

$a

$b

return $a + $b

}

 

If I call this function with

Add 10 17 # the syntax for calling powershell is WITHOUT comma – the comma indicates arry

it shows

10

17

27

However , if I wrote

$x = Add 10 17

it does not wrote

10

17

 

Do you know why ?

 

Answer in the first comment

powershell and clean iis

Sometimes it is necessary to remove IIS temp files from windows directory

So I have made this following script in powershell

iis reset

What it does:
restarts iis ( run as admin in Windows 7)

Cleans temporary folders from

$windir + “\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files”

$windir + “\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files”

Enjoy !(iis reset)