In Power SHell set alias cp to cp -v

2

1

I have cp for power shell. But I want to use cp in verbose mode without writing -v. So cp should be aliased to "cp -v" command. How to alias cp to "cp -v" in power shell?

Narek

Posted 2012-08-28T15:59:42.760

Reputation: 1 251

What are you really trying to do? – kinokijuf – 2012-08-28T16:12:46.697

I have cp for power shell. But I want to use cp in verbose mode without writing -v. So cp should be aliased to "cp -v" command. – Narek – 2012-08-28T16:18:54.647

Answers

2

The alias command will not create parameters. You'll have to delete the existing alias for cp and use a function:

Remove-Item alias:cp
Function cp { Copy-Item -v @args }

See here.

Kasius

Posted 2012-08-28T15:59:42.760

Reputation: 498

1

Create a new alias for calling cp with the Verbose flag:

function Copy-ItemWithVerbose
{
    Copy-Item -Verbose @args 
}
Set-Alias -Name cpv -Value Copy-ItemWithVerbose

splattered bits

Posted 2012-08-28T15:59:42.760

Reputation: 173

0

in PS3 you can use this:

PS III> $PSDefaultParameterValues.Add("Copy-item:verbose","$true")
PS III> cp

walid2mi

Posted 2012-08-28T15:59:42.760

Reputation: 126