Script doesn't work when compiled to .exe
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- Chris_Ediger
- Posts: 45
- Last visit: Tue May 09, 2023 8:35 pm
Re: Script doesn't work when compiled to .exe
Still doesn't work. I get a built in error that I put into my script but I'm guessing it is because of the same problem as before.
This is the full first part of the script. When I compile as a Windows form I get as far as prompting for credentials then I get my username/password not correct error. This works just fine before I compile it.
$CreateNewUser_Load={
#TODO: Initialize Form Controls here
$Global:ADUsers = Get-ADUser -Filter * -Properties DisplayName,DistinguishedName,HomeDirectory,Department,MemberOf,SAMAccountName,CN,EmailAddress -SearchBase "<mysearchbase>" | Where-Object { $_.DisplayName -notlike "zz*" }
$ADUserDisplayNames = $ADUsers | Select-Object -ExpandProperty DisplayName
do {
$Global:DomainAdminCredentials = Get-Credential -message "Enter Domain Admin credentials" #Read credentials
$username = $DomainAdminCredentials.username
$password = $DomainAdminCredentials.GetNetworkCredential().password
# Get current domain using logged-on user's credentials
$CurrentDomain = "LDAP://" + ([adsi]"").DistinguishedName
$domain = New-Object System.DirectoryServices.DirectoryEntry ($CurrentDomain, $UserName, $Password)
if ($domain.Name -eq $null) {
[void][System.Windows.Forms.MessageBox]::Show("Username or Password Incorrect", "Warning")
$Authenticated = $false
}
else {
$Authenticated = $true
}
}
while ($Authenticated -eq $false)
Is there any way to log what is going on when the script executes?
This is the full first part of the script. When I compile as a Windows form I get as far as prompting for credentials then I get my username/password not correct error. This works just fine before I compile it.
$CreateNewUser_Load={
#TODO: Initialize Form Controls here
$Global:ADUsers = Get-ADUser -Filter * -Properties DisplayName,DistinguishedName,HomeDirectory,Department,MemberOf,SAMAccountName,CN,EmailAddress -SearchBase "<mysearchbase>" | Where-Object { $_.DisplayName -notlike "zz*" }
$ADUserDisplayNames = $ADUsers | Select-Object -ExpandProperty DisplayName
do {
$Global:DomainAdminCredentials = Get-Credential -message "Enter Domain Admin credentials" #Read credentials
$username = $DomainAdminCredentials.username
$password = $DomainAdminCredentials.GetNetworkCredential().password
# Get current domain using logged-on user's credentials
$CurrentDomain = "LDAP://" + ([adsi]"").DistinguishedName
$domain = New-Object System.DirectoryServices.DirectoryEntry ($CurrentDomain, $UserName, $Password)
if ($domain.Name -eq $null) {
[void][System.Windows.Forms.MessageBox]::Show("Username or Password Incorrect", "Warning")
$Authenticated = $false
}
else {
$Authenticated = $true
}
}
while ($Authenticated -eq $false)
Is there any way to log what is going on when the script executes?
- Chris_Ediger
- Posts: 45
- Last visit: Tue May 09, 2023 8:35 pm
- Chris_Ediger
- Posts: 45
- Last visit: Tue May 09, 2023 8:35 pm
Re: Script doesn't work when compiled to .exe
Why does it work when I run it from within PSS? It only fails when I compile it. And why do scripts that previously compiled properly now fail?
Re: Script doesn't work when compiled to .exe
Unfortunately there is not enough information to answer your question. Somewhere you have changed something that is causing your packager to work differently. Be sure you are using all of the correct settings for STA/host type and architecture.
- Chris_Ediger
- Posts: 45
- Last visit: Tue May 09, 2023 8:35 pm
Re: Script doesn't work when compiled to .exe
What settings might I have changed? Are there others besides those in the packager settings?
Re: Script doesn't work when compiled to .exe
What settings are you using? What is your script trying to do? What are the problems?
Without accurate information no one can be of much help.
Have you tried running from a new account? Have you tried repairing your system?
Without accurate information no one can be of much help.
Have you tried running from a new account? Have you tried repairing your system?
Re: Script doesn't work when compiled to .exe
Also if these are all AD scripts with the same error perhaps you have issues with the AD servers or the network.
Without an accurate error message it would be very hard to analyze this.
Without an accurate error message it would be very hard to analyze this.