Requesting assistance, I am creating the script where I need to move the input data from the function to another variable. Then I used this variable to populate a word template as well as a text file.
My code is as follows
<code>Function Filename($file) {
[void][System.Reflection.Assembly]::LoadWithPartialName(Microsoft.VisualBasic)
$title = 'My File name'
$msg = 'Enter the file name'
$file = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title)
[System.Windows.MessageBox]::show($file, 'File Name')
$global:file
}
$filename = Filename
</code>
<code>Function Filename($file) {
[void][System.Reflection.Assembly]::LoadWithPartialName(Microsoft.VisualBasic)
$title = 'My File name'
$msg = 'Enter the file name'
$file = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title)
[System.Windows.MessageBox]::show($file, 'File Name')
$global:file
}
$filename = Filename
</code>
Function Filename($file) {
[void][System.Reflection.Assembly]::LoadWithPartialName(Microsoft.VisualBasic)
$title = 'My File name'
$msg = 'Enter the file name'
$file = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title)
[System.Windows.MessageBox]::show($file, 'File Name')
$global:file
}
$filename = Filename
I am unable to use the value at global scope.
Please help
When I do this i.e.
<code>write-host $filename.
</code>
<code>write-host $filename.
</code>
write-host $filename.
The script runs but file name never print.