Hi, this is Poshland blog about basics Powershell for everyone.
Last on Reddit forum I reply for one person how to insert variable to script without script editing. Today I thought that it can be subject to next post. So Let’s check what is param block.
Remember what is variable
Few posts ago I write My Way to understand Powershell variable. It shows you what is it variable. One of the next posts was about Powershell
You don’t have to edit script to change variable. Use Powershell param block.
In the past, a long time ago when I started with Powershell, I was writing very basics script. My scripts were very basics because I wasn’t using functions, param etc. Whenever I wanted to use my old Powershell script, I had to edit it to change a
Now I know Powershell much better and I will share with you

param (
[string]$path,
[string]$Type
)
Write-Host "This is my $path"
Write-Host "This is My $Type"
Write-Host "So I can use $path and $Type inserted during script start"
Powershell function – better way to write the script
When you write a few line script to do something I think the better way is to write Powershell function, because you can use it in the next script if you needed. I don’t write all information about Powershell function because there is enough information to write a separate post. I will show you only

function Start-FunctionWithParam {
param (
[string]$path,
[string]$Type
)
Write-Host "This is my $path"
Write-Host "This is My $Type"
Write-Host "So I can use $path and $Type inserted during script start"
}
Start-FunctionWithParam -path MyNewPath -Type $MyNewtype
Script and functions – how to use them together
When we know how to use param block in Powershell script and Powershell function, it’s time to check how it works together. Below I show Powershell script with function. I think that example will be the better description.

param (
[string]$Path1,
[string]$Type1
)
function Start-FunctionWithParam {
param (
[string]$path,
[string]$Type
)
Write-Host "This is my $path"
Write-Host "This is My $Type"
Write-Host "So I can use $path and $Type inserted during script start"
}
Start-FunctionWithParam -path $path1 -Type $Type1
Conclusion
I want to tell