Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Powershell script modify

$
0
0

I am modifying an exiting powershell script other person wrote.

at the top of the powershell, it  looks like this:

[CmdletBinding()]
param (
    [switch]$isTest
)
$locMod = ""
if ($isTest) {
    $locMod = "test"
}
$outloc = '\\remoteserver\sis{0}\Project\OUT' -f $locMod
$output = "$outloc\myfile.csv"
$outlog = "$outloc\mylog.txt"

..........

Now I would like to modify the script to use a local drive:

Instead of using \\remoteserver\sis{0}\Project\OUT but just use : c:\export.

This does not matter it is a test server or prod, for they exist for both.

so I am thinking to change it to:

[CmdletBinding()]

$outloc = 'c:\export'  
$output = "$outloc\myfile.csv"
$outlog = "$outloc\mylog.txt"

I don't need to check isTest or not, what should I remove:

I think to remove the following lines in bold, but not sure.

[CmdletBinding()]
param (
    [switch]$isTest
)
$locMod = ""
if ($isTest) {
    $locMod = "test"
}
$outloc = '\\remoteserver\sis{0}\Project\OUT' -f $locMod
$output = "$outloc\myfile.csv"
$outlog = "$outloc\mylog.txt"

Please advice.

Is still [CmdletBinding()] necessary, can it exist without param() line?


Thanks




Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>