NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform. You will still be able to view content, but posting and replying will be temporarily disabled.
We're excited to launch our new Community experience on July 30 and more information will follow soon.
Stay connected during the transition - Join our Discord community today.

Microsoft Virtualization Discussions

How to add $ at the end of the user provided information.

koushi
5,589 Views

How to add $ at the end of the user provided information.
My Qtree should be add with _q at the end once user provided qtree as test then it should be tree_q
My sharename should be add with $ at the end once user provided qtree as test then it should be tree$

 

For more information

 

$qtreename = Read-Host -Prompt 'Input your QTREE  name'

 

New-NcQtree -Volume $volumename -Qtree $qtreename -SecurityStyle ntfs -Vserver $vservername  # here Qtree name need to be append as '_q' at the end of qtree name

 

Add-NcCifsShare -Name $share -Path $pathname1 -SymlinkProperties hide -OfflineFilesMode Manual -VscanProfile strict -Vserver $vservername #  Here sharename should follows with Qtreename$ as powershell takes $ as input of the variable im facing few challenges

 

can anyone please help

1 ACCEPTED SOLUTION

Aparajita
5,581 Views

Escaping the $ with "`" should do the trick ...

 

$qtreename = Read-Host -Prompt 'Input your QTREE  name'
$qtreename = $qtreename + "_q" #Append _q to the qtree name that was input

New-NcQtree -Volume $volumename -Qtree $qtreename -SecurityStyle ntfs -Vserver $vservername

$share = "`$$qtreename" #` is the escape character in PowerShell
Add-NcCifsShare -Name $share -Path $pathname1 -SymlinkProperties hide -OfflineFilesMode Manual -VscanProfile strict -Vserver $vservername

Hope this helps,

Aparajita

View solution in original post

3 REPLIES 3

Aparajita
5,582 Views

Escaping the $ with "`" should do the trick ...

 

$qtreename = Read-Host -Prompt 'Input your QTREE  name'
$qtreename = $qtreename + "_q" #Append _q to the qtree name that was input

New-NcQtree -Volume $volumename -Qtree $qtreename -SecurityStyle ntfs -Vserver $vservername

$share = "`$$qtreename" #` is the escape character in PowerShell
Add-NcCifsShare -Name $share -Path $pathname1 -SymlinkProperties hide -OfflineFilesMode Manual -VscanProfile strict -Vserver $vservername

Hope this helps,

Aparajita

JGPSHNTAP
5,566 Views

^^

Unless i'm reading this wrong, I don't think that's what he's asking for..

 

You want to know how to add $ to the end of a share before you create it so it's hidden, right?

koushi
5,562 Views

Hey JGPSHNTAP,

 

The one which im looking for is been answered by Aparajita.

As powershell never allow $ at the end we can user '$ at the end will works..

 

I tried the same and it worked.

 

Thanks to both of you.

 

 

 

Public