Hi ExpertsPlease help in fixing the issues. The variable values from one function to another is not being passed and thereby in show grid, no data is being displayed.Please suggest a best way to send the data:-function AcceptedFeatures{ [CmdletBinding()] Param ( [Parameter(Position=0,Mandatory=$false)][string]$action ,[Parameter(Position=1,Mandatory=$false)][string]$INSTANCENAME #for default only provide 'MSSQLSERVER', for Other named Instance just input the instance name you like. #,[Parameter(Position=2,Mandatory=$true)][string]$default #$default = 0 (for default, 1 = Named) ) Begin { $VerbosePreference = 'Continue' $DebugPreference = 'Continue' }Process{ #Int $retrycount = 0 #Int $retries = 5 $val = 0$val = [int] $val$val#$args.ErrorAction = "Stop" try { while ($val -ne 3) { $PATH = read-host "Enter the complete path to read from the file: [i.e. ""C:\test\SQLServer2012ConfigurationFile_Install.ini""; Dont include Double Quote or single Quote]" #$PATH IF($PATH -ne "") { #write-host $PATH -ForegroundColor YELLOW IF (-NOT (Test-Path -path $PATH)) { #Throw "$($PATH) is not a valid folder" write-host "Please Re-Enter the File Name with Proper Path `n `r" -ForegroundColor red $val++; write-host "testing 1:" $val } else{ write-host "Correct Filename Entered :" $PATH -ForegroundColor CYAN #$val = 5 $val ++; break } } ELSE{ write-host "testing 2:" $val write-host "Re-Enter the File Name with Proper Path `n `r" -ForegroundColor red $val++; write-host $val; } if ($val -eq 3) {return} }} catch [System.Exception] { write-host "Error." write-host $error[0].Exception.ToString() throw }#$PATH = "C:\test\SQLServer2012ConfigurationFile_Install.ini"$ACTION = Get-Content $PATH | Where-Object {$_ -match 'ACTION='} $pos = $ACTION.IndexOf("=")#$leftPart = $SQLSVCACCOUNT.Substring(0, $pos)$rightPart = $ACTION.Substring($pos+1)$ACTION = $rightPart -replace '"', "" #$Global:ACTION#$script:ACTION#$ACTION$FEATURES = Get-Content $path | Where-Object {$_ -match 'FEATURES='} $pos = $FEATURES.IndexOf("=")#$leftPart = $SQLSVCACCOUNT.Substring(0, $pos)$rightPart = $FEATURES.Substring($pos+1)$FEATURES = $rightPart -replace "`'", "`""$FEATURES = "'" + $FEATURES +"'"$Global:FEATURES#$FEATURES$INSTALLSHAREDDIR = Get-Content $path | Where-Object {$_ -match 'INSTALLSHAREDDIR='} $pos = $INSTALLSHAREDDIR.IndexOf("=")#$leftPart = $SQLSVCACCOUNT.Substring(0, $pos)$rightPart = $INSTALLSHAREDDIR.Substring($pos+1)$INSTALLSHAREDDIR = $rightPart -replace '"', "" $INSTALLSHAREDDIR$INSTALLSHAREDWOWDIR = Get-Content $path | Where-Object {$_ -match 'INSTALLSHAREDWOWDIR='} $pos = $INSTALLSHAREDWOWDIR.IndexOf("=")#$leftPart = $SQLSVCACCOUNT.Substring(0, $pos)$rightPart = $INSTALLSHAREDWOWDIR.Substring($pos+1)$INSTALLSHAREDWOWDIR = $rightPart -replace '"', "" $INSTALLSHAREDWOWDIR#$Global:INSTANCENAME#$Global:INSTANCEID$INSTANCENAME = Get-Content $path | Where-Object {$_ -match 'INSTANCENAME='} $pos = $INSTANCENAME.IndexOf("=")#$leftPart = $SQLSVCACCOUNT.Substring(0, $pos)$rightPart = $INSTANCENAME.Substring($pos+1)$INSTANCENAME = $rightPart -replace '"', "" $INSTANCENAME$INSTANCEID = Get-Content $path | Where-Object {$_ -match 'INSTANCEID='} $pos = $INSTANCEID.IndexOf("=")#$leftPart = $SQLSVCACCOUNT.Substring(0, $pos)$rightPart = $INSTANCEID.Substring($pos+1)$INSTANCEID = $rightPart -replace '"', "" $INSTANCEID$INSTANCEDIR = Get-Content $path | Where-Object {$_ -match 'INSTANCEDIR='} $pos = $INSTANCEDIR.IndexOf("=")#$leftPart = $SQLSVCACCOUNT.Substring(0, $pos)$rightPart = $INSTANCEDIR.Substring($pos+1)$INSTANCEDIR = $rightPart -replace '"', "" $INSTANCEDIR$AGTSVCSTARTUPTYPE = Get-Content $path | Where-Object {$_ -match 'AGTSVCSTARTUPTYPE='} $pos = $AGTSVCSTARTUPTYPE.IndexOf("=")#$leftPart = $SQLSVCACCOUNT.Substring(0, $pos)$rightPart = $AGTSVCSTARTUPTYPE.Substring($pos+1)$AGTSVCSTARTUPTYPE = $rightPart -replace '"', "" $AGTSVCSTARTUPTYPE$SQLSVCSTARTUPTYPE = Get-Content $path | Where-Object {$_ -match 'SQLSVCSTARTUPTYPE='} $pos = $SQLSVCSTARTUPTYPE.IndexOf("=")#$leftPart = $SQLSVCACCOUNT.Substring(0, $pos)$rightPart = $SQLSVCSTARTUPTYPE.Substring($pos+1)$SQLSVCSTARTUPTYPE = $rightPart -replace '"', "" $SQLSVCSTARTUPTYPE$SQLCOLLATION = Get-Content $path | Where-Object {$_ -match 'SQLCOLLATION='} $pos = $SQLCOLLATION.IndexOf("=")#$leftPart = $SQLSVCACCOUNT.Substring(0, $pos)$rightPart = $SQLCOLLATION.Substring($pos+1)$SQLCOLLATION = $rightPart -replace '"', "" $SQLCOLLATION$SQLSVCACCOUNT = Get-Content $path | Where-Object {$_ -match 'SQLSYSADMINACCOUNTS='} $pos = $SQLSVCACCOUNT.IndexOf("=")$rightPart = $SQLSVCACCOUNT.Substring($pos+1)$SQLSVCACCOUNT = $rightPart -replace '"', "" $SQLSVCACCOUNT = """$SQLSVCACCOUNT""" -replace '\s', ', '$SQLSVCACCOUNT$SQLSYSADMINACCOUNTS = Get-Content $path | Where-Object {$_ -match 'SQLSYSADMINACCOUNTS='} $pos = $SQLSYSADMINACCOUNTS.IndexOf("=")#$leftPart = $SQLSVCACCOUNT.Substring(0, $pos)$rightPart = $SQLSYSADMINACCOUNTS.Substring($pos+1)$SQLSYSADMINACCOUNTS = $rightPart -replace '"', "" $SQLSYSADMINACCOUNTS = """$SQLSYSADMINACCOUNTS""" -replace '\s', ', '$SQLSYSADMINACCOUNTS$SQLUSERDBDIR = Get-Content $path | Where-Object {$_ -match 'SQLUSERDBDIR='} #$SQLTEMPDBDIR = $SQLTEMPDBDIR -replace '"', ""$pos = $SQLUSERDBDIR.IndexOf("=")#$leftPart = $SQLSVCACCOUNT.Substring(0, $pos)$SQLUSERDBDIR1 = $SQLUSERDBDIR.Substring($pos+1)$SQLUSERDBDIR1 = $SQLUSERDBDIR1 -replace '"', ""$SQLUSERDBDIR = $SQLUSERDBDIR1 +'\'+$INSTANCENAME+'\'$SQLUSERDBDIR#SQLUSERDBLOGDIR PATH$SQLUSERDBLOGDIR = Get-Content $path | Where-Object {$_ -match 'SQLUSERDBLOGDIR='} #$SQLTEMPDBDIR = $SQLTEMPDBDIR -replace '"', ""$pos = $SQLUSERDBLOGDIR.IndexOf("=")#$leftPart = $SQLSVCACCOUNT.Substring(0, $pos)$SQLUSERDBLOGDIR1 = $SQLUSERDBLOGDIR.Substring($pos+1)$SQLUSERDBLOGDIR1 = $SQLUSERDBLOGDIR1 -replace '"', ""$SQLUSERDBLOGDIR = $SQLUSERDBLOGDIR1 +'\'+$INSTANCENAME+'\'$SQLUSERDBLOGDIR#Tempdb path$SQLTEMPDBDIR =""$SQLTEMPDBDIR = Get-Content $path | Where-Object {$_ -match 'SQLTEMPDBDIR='} #$SQLTEMPDBDIR = $SQLTEMPDBDIR -replace '"', ""$pos = $SQLTEMPDBDIR.IndexOf("=")#$leftPart = $SQLSVCACCOUNT.Substring(0, $pos)$SQLTEMPDBDIR1 = $SQLTEMPDBDIR.Substring($pos+1)$SQLTEMPDBDIR1 = $SQLTEMPDBDIR1 -replace '"', ""$SQLTEMPDBDIR = $SQLTEMPDBDIR1 +'\'+$INSTANCENAME+'\'$SQLTEMPDBDIR$TCPENABLED = Get-Content $path | Where-Object {$_ -match 'TCPENABLED='} $pos = $TCPENABLED.IndexOf("=")#$leftPart = $SQLSVCACCOUNT.Substring(0, $pos)$rightPart = $TCPENABLED.Substring($pos+1)$TCPENABLED = $rightPart -replace '"', "" $TCPENABLED<#IF ($TCPENABLED -eq 0){#Print $TCPENABLEDWrite-Host "Disabled"}ELSEIF($TCPENABLED -eq 1){ #Print $TCPENABLED Write-Host "Enabled" }$TCPENABLED#>write-host ".............17 selected features during SQL Install............."$hash = @{ ACTION = $ACTION FEATURES = $FEATURES INSTALLSHAREDDIR = $INSTALLSHAREDDIR INSTALLSHAREDWOWDIR = $INSTALLSHAREDWOWDIR INSTANCENAME = $INSTANCENAME INSTANCEID = $INSTANCEID INSTANCEDIR = $INSTANCEDIR AGTSVCACCOUNT = $AGTSVCACCOUNT AGTSVCSTARTUPTYPE = $AGTSVCSTARTUPTYPE SQLSVCSTARTUPTYPE = $SQLSVCSTARTUPTYPE SQLCOLLATION = $SQLCOLLATION SQLSVCACCOUNT = $SQLSVCACCOUNT SQLSYSADMINACCOUNTS = $SQLSYSADMINACCOUNTS SQLUSERDBDIR = $SQLUSERDBDIR SQLUSERDBLOGDIR = $SQLUSERDBLOGDIR SQLTEMPDBDIR = $SQLTEMPDBDIR TCPENABLED = $TCPENABLED } $Object = New-Object PSObject -Property $hash $Objectwrite-host ".......................END OF SELECTION......................."}} # END OF fn: AcceptedFeaturesAcceptedFeaturesfunction ShowinOutGrid(){AcceptedFeatures#$List1 = "";$List1 = @()$List1 += [pscustomobject]@{Property = "Action"Value = $ACTION}$List1 += [pscustomobject]@{Property = "INSTALLSHAREDDIR"Value = $INSTALLSHAREDDIR}$List1 += [pscustomobject]@{Property = "INSTALLSHAREDWOWDIR"Value = $INSTALLSHAREDWOWDIR}$List1 += [pscustomobject]@{Property = "INSTALLSHAREDWOWDIR"Value = $INSTALLSHAREDWOWDIR}$List1 += [pscustomobject]@{Property = "INSTANCENAME"Value = $INSTANCENAME}$List1 += [pscustomobject]@{Property = "INSTANCEID"Value = $INSTANCEID}$List1 += [pscustomobject]@{Property = "INSTANCEDIR"Value = $INSTANCEDIR}$List1 += [pscustomobject]@{Property = "AGTSVCACCOUNT"Value = $AGTSVCACCOUNT}$List1 += [pscustomobject]@{Property = "AGTSVCSTARTUPTYPE"Value = $AGTSVCSTARTUPTYPE}$List1 += [pscustomobject]@{Property = "SQLSVCSTARTUPTYPE"Value = $SQLSVCSTARTUPTYPE}$List1 += [pscustomobject]@{Property = "SQLCOLLATION"Value = $SQLCOLLATION}$List1 += [pscustomobject]@{Property = "SQLSVCACCOUNT"Value = $SQLSVCACCOUNT}$List1 += [pscustomobject]@{Property = "SQLSYSADMINACCOUNTS"Value = $SQLSYSADMINACCOUNTS}$List1 += [pscustomobject]@{Property = "SQLUSERDBDIR"Value = $SQLUSERDBDIR}$List1 += [pscustomobject]@{Property = "SQLUSERDBLOGDIR"Value = $SQLUSERDBLOGDIR}$List1 += [pscustomobject]@{Property = "SQLTEMPDBDIR"Value = $SQLTEMPDBDIR}$List1 += [pscustomobject]@{Property = "TCPENABLED"Value = $TCPENABLED}$List1 | Out-GridView -wait}ShowinOutGrid
↧