0

I whant to create driver for own variables in own scope.
For example $myown:name = value

I tried to do that with different values for -Root:

New-PSDrive -Name myown -PSProvider Variable -Root /myown/

But that driver works like variable:.

compare (ls myown:) (ls variable:)
# no changes

How to create psdriver for variables that will work not like variable: psdrive?

$variable:name and $myown:name must be different.

Edited1:

What I want to do

I'm going to create module for loading WPF forms from .xaml.
And all elements with x:Name property must be imported to new PSDriver named like loaded form.

Load-WPF form1.xaml -OutVariable form1
$form1 # loaded WPF form
# and all form's elements added to form1: provider
$form1:button1  # <Button  x:Name="button1"  ../>
$form1:textbox1 # <TextBox x:Name="textbox1" ../>
groser
  • 319
  • 1
  • 11
  • What exact problem are you trying to solve here? If you create a variable in module scope or a local script scope it will only be available there anyways – Mathias R. Jessen Sep 20 '20 at 14:15
  • Ditto with what Mathias said, and are you sure you are looking at the New-PSDrive cmdlet use case correctly? For example as per the docs [-Root Specifies the data store location to which a PowerShell drive is mapped.] – postanote Sep 20 '20 at 22:45
  • Why do they have to be a drive? When I do it I simply create a vaiable to store all of it... `$SyncHash.Window`,`$SyncHash.Button1`,`$SyncHash.TextBox1`... – T-Me Sep 22 '20 at 10:50

0 Answers0