Hello,
When I try to run a script (from another computer this time) I got the following error (I only removed IP-adress)
I read about that might cause by Office? So I have installed 64bit on a 64bit Windows server. Otherwise I'm using the same Office installation at home.
Even if it says that F21ABCD already exists on the folder \Computers\ I can still proceed with the installation
The script:
function Set-OSDComputerName {
$ErrorProvider.Clear()
$lastFour = $TBComputerName.text.substring($TBComputerName.text.length -4,4) # Get the last 4 caharcters of computer name
$badstring = select-string -path "\\IP\DS\bad_words.txt" -pattern $lastfour
if ($badstring) {
$ErrorProvider.SetError($GBComputerName, "Computer name cannot be more than 6 characters")
return
}
if ($TBComputerName.Text.Length -eq 0) {
$ErrorProvider.SetError($GBComputerName, "Please enter a computer name")
return
}
if ($TBComputerName.Text.Length -gt 7) {
$ErrorProvider.SetError($GBComputerName, "Computer name cannot be more than 6 characters")
return
}
if ($TBComputerName.Text -notmatch '^[F][0-9]{2,2}[a-zA-Z]{4,4}$') {
$ErrorProvider.SetError($GBComputerName, "Computer name must be named with <F> and <numbers> and <four random letters>")
return
}
if ($badstring) {
$ErrorProvider.SetError($GBComputerName, "Please enter a computer name")
return
}
else {
$OSDComputerName = $TBComputerName.Text -replace "[\[\]:;|=+*?<>\/,]+", ''
$temp_file = $temp_path + $OSDComputerName + ".txt"
if (Select-String -Path "\\IP\DS\bad_words.txt" -Pattern $TBComputerName.text.substring($TBComputerName.text.Length - 4, 4)) {
$ErrorProvider.SetError($GBComputerName, "Computer name contains a bad word, not acceptable")
return
}
else {
New-Item -Path "\\IP\DS\Computers\$OSDComputerName" -ItemType File | Out-Null
$ErrorProvider.SetError($GBComputerName, "Computer name contains a bad word, not acceptable")
}
$TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$TSEnv.Value("OSDComputerName") = "$($OSDComputerName)"
$Form.Close()
}
}