Reputation: 4352
trying to do something insanely simple in PS but for some odd reason it is just not playing ball. My PS script looks like:
For some reason its complaining about the fact that:
enableMSDTC : The term 'enableMSDTC' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Am I not allowed to do this? I have to have a separate script file for each function?
Thanks in advance, DS.
param
(
[string]$folder = $(throw 'Local folder to map to is required.')
)
begin
{
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
}
process
{
$hasDrive = Test-Path -Path "D:\"
if ($hasDrive -eq $true) {
echo "Enabling MSDTC settings..."
enableMSDTC
}
Function enableMSDTC() {
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\MSDTC\Security" -Name "LuTransactions" -Value "1"
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\MSDTC\Security" -Name "NetworkDtcAccess" -Value "1"
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\MSDTC\Security" -Name "NetworkDtcAccessAdmin" -Value "1"
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\MSDTC\Security" -Name "NetworkDtcAccessClients" -Value "1"
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\MSDTC\Security" -Name "NetworkDtcAccessInbound" -Value "1"
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\MSDTC\Security" -Name "NetworkDtcAccessOutbound" -Value "1"
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\MSDTC\Security" -Name "NetworkDtcAccessTransactions" -Value "1"
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\MSDTC\Security" -Name "NetworkDtcAccessXaTransactions" -Value "1"
}
}
Upvotes: 0
Views: 613
Reputation: 65147
Powershell is an interpreted language, which means commands are parsed in order (top down) at run time.
You can't call a function or refer to a variable before you define it.
Upvotes: 0