Powershell Default User
-
@lakshmana said in Powershell Default User:
fault or current user in the Powershell. Like in .bat file we can mention C:%username%\
More info here:
https://technet.microsoft.com/en-us/library/ff730963.aspx -
@dbeato
Param (
[string]$file = 'C:%USERNAME%\fILENAME'
)in my powershell how to rename here ?
-
@lakshmana said in Powershell Default User:
@dbeato
Param (
[string]$file = 'C:%USERNAME%\fILENAME'
)in my powershell how to rename here ?
Param ( [string]$file = 'C:\$env:UserName\fILENAME' )
-
@dbeato said in Powershell Default User:
[string]$file = 'C:$env:UserName\fILENAME'
)Get-Item : Cannot find path 'C:$env:Username\Tickets' because it does not exist.
-
@lakshmana said in Powershell Default User:
@dbeato said in Powershell Default User:
[string]$file = 'C:$env:UserName\fILENAME'
)Get-Item : Cannot find path 'C:$env:Username\Tickets' because it does not exist.
Can you declare it before the string then into a variable?
-
@lakshmana said in Powershell Default User:
@dbeato said in Powershell Default User:
[string]$file = 'C:$env:UserName\fILENAME'
)Get-Item : Cannot find path 'C:$env:Username\Tickets' because it does not exist.
It should be
'C:\Users\$env:USERNAME\filename'
-
@black3dynamite said in Powershell Default User:
@lakshmana said in Powershell Default User:
@dbeato said in Powershell Default User:
[string]$file = 'C:$env:UserName\fILENAME'
)Get-Item : Cannot find path 'C:$env:Username\Tickets' because it does not exist.
It should be
'C:\Users\$env:USERNAME\filename'
That's right...
-
@dbeato said in Powershell Default User:
@black3dynamite said in Powershell Default User:
@lakshmana said in Powershell Default User:
@dbeato said in Powershell Default User:
[string]$file = 'C:$env:UserName\fILENAME'
)Get-Item : Cannot find path 'C:$env:Username\Tickets' because it does not exist.
It should be
'C:\Users\$env:USERNAME\filename'
That's right...
Get-Item : Cannot find path 'C:\Users$env:USERNAME\filename' because it does not exist.
-
@lakshmana said in Powershell Default User:
@dbeato said in Powershell Default User:
@black3dynamite said in Powershell Default User:
@lakshmana said in Powershell Default User:
@dbeato said in Powershell Default User:
[string]$file = 'C:$env:UserName\fILENAME'
)Get-Item : Cannot find path 'C:$env:Username\Tickets' because it does not exist.
It should be
'C:\Users\$env:USERNAME\filename'
That's right...
Get-Item : Cannot find path 'C:\Users$env:USERNAME\filename' because it does not exist.
Still missing the \
-
@scottalanmiller Its already there when i am copy pasting its not showing
-
@scottalanmiller said in Powershell Default User:
@lakshmana said in Powershell Default User:
@dbeato said in Powershell Default User:
@black3dynamite said in Powershell Default User:
@lakshmana said in Powershell Default User:
@dbeato said in Powershell Default User:
[string]$file = 'C:$env:UserName\fILENAME'
)Get-Item : Cannot find path 'C:$env:Username\Tickets' because it does not exist.
It should be
'C:\Users\$env:USERNAME\filename'
That's right...
Get-Item : Cannot find path 'C:\Users$env:USERNAME\filename' because it does not exist.
Still missing the \
If you quote it, it shows. I am not sure if it is a bug on NodeBB.
-
@lakshmana said in Powershell Default User:
@scottalanmiller Its already there when i am copy pasting its not showing
Oh, you have to escape it.
-
This is a small sample I did and it worked:
-
Are you sure that the filename exists?
-
Better example:
-
@scottalanmiller said in Powershell Default User:
Are you sure that the filename exists?
The files exists inside that folder and before doing this i have mentioned as in .bat but that has to runned in the all the machine means it should get the current user details so only asked for the same which is not working when tried to execute in the powershell
-
@lakshmana said in Powershell Default User:
@scottalanmiller said in Powershell Default User:
Are you sure that the filename exists?
The files exists inside that folder and before doing this i have mentioned as in .bat but that has to runned in the all the machine means it should get the current user details so only asked for the same which is not working when tried to execute in the powershell
So are you running this via a task or when the user logs in?
-
@lakshmana said in Powershell Default User:
@dbeato said in Powershell Default User:
@black3dynamite said in Powershell Default User:
@lakshmana said in Powershell Default User:
@dbeato said in Powershell Default User:
[string]$file = 'C:$env:UserName\fILENAME'
)Get-Item : Cannot find path 'C:$env:Username\Tickets' because it does not exist.
It should be
'C:\Users\$env:USERNAME\filename'
That's right...
Get-Item : Cannot find path 'C:\Users$env:USERNAME\filename' because it does not exist.
C:\$env:Username\Tickets
should be'C:\Users\$env:USERNAME\Tickets'
-
@black3dynamite said in Powershell Default User:
@lakshmana said in Powershell Default User:
@dbeato said in Powershell Default User:
@black3dynamite said in Powershell Default User:
@lakshmana said in Powershell Default User:
@dbeato said in Powershell Default User:
[string]$file = 'C:$env:UserName\fILENAME'
)Get-Item : Cannot find path 'C:$env:Username\Tickets' because it does not exist.
It should be
'C:\Users\$env:USERNAME\filename'
That's right...
Get-Item : Cannot find path 'C:\Users$env:USERNAME\filename' because it does not exist.
C:\$env:Username\Tickets
should be'C:\Users\$env:USERNAME\Tickets'
I have changed already
-
@dbeato said in Powershell Default User:
@lakshmana said in Powershell Default User:
@scottalanmiller said in Powershell Default User:
Are you sure that the filename exists?
The files exists inside that folder and before doing this i have mentioned as in .bat but that has to runned in the all the machine means it should get the current user details so only asked for the same which is not working when tried to execute in the powershell
So are you running this via a task or when the user logs in?
This is the powershell which converts into .csv to .xlsx in the machine in the folder mentioned