creative555
asked on
Please help with this VB script -#Requires -version 3 what is that?
Hi,
I am trying to run this script to import GPOs from the backup and it is failing with the errors because I need to specify the required parameter but don't know how and what they are. Could you please explain what I need to provide here.
Thank you!
########################## #######
## Script Options and Parameters
########################## #######
#Requires -version 3 (???? Not sure...
#Requires -modules ActiveDirectory,GroupPolic y (OK. I got this part)
#Version: 2.0 (???? I am not sure about this one)
#Define and validate parameters (What do I need to provide here???? and where??)
[CmdletBinding()]
Param(
#The target domain
[parameter(Mandatory=$True ,Position= 1)]
[ValidateScript({Get-ADDom ain $_})]
[String]$Domain,
#The source backup folder
[parameter(Mandatory=$True ,Position= 2)]
[ValidateScript({Test-Path $_})]
[String]$BackupFolder,
# Whether to reference a migration table (?????) How to provide it?
[Switch]
$MigTable,
# Whether to import SOM information (??? )
[Switch]
$SomInfo,
# Whether to import WMI filter information (?????? should this me a path or somthing or domain???)
[Switch]
$WmiFilter
)
#Set strict mode to identify typographical errors (uncomment whilst editing script)
#Set-StrictMode -version Latest
########################## ########## ########## ########## ########## ########## ########## ########## ##########
########################## ####
## FUNCTION - Log-ScriptEvent
I am trying to run this script to import GPOs from the backup and it is failing with the errors because I need to specify the required parameter but don't know how and what they are. Could you please explain what I need to provide here.
Thank you!
##########################
## Script Options and Parameters
##########################
#Requires -version 3 (???? Not sure...
#Requires -modules ActiveDirectory,GroupPolic
#Version: 2.0 (???? I am not sure about this one)
#Define and validate parameters (What do I need to provide here???? and where??)
[CmdletBinding()]
Param(
#The target domain
[parameter(Mandatory=$True
[ValidateScript({Get-ADDom
[String]$Domain,
#The source backup folder
[parameter(Mandatory=$True
[ValidateScript({Test-Path
[String]$BackupFolder,
# Whether to reference a migration table (?????) How to provide it?
[Switch]
$MigTable,
# Whether to import SOM information (??? )
[Switch]
$SomInfo,
# Whether to import WMI filter information (?????? should this me a path or somthing or domain???)
[Switch]
$WmiFilter
)
#Set strict mode to identify typographical errors (uncomment whilst editing script)
#Set-StrictMode -version Latest
##########################
##########################
## FUNCTION - Log-ScriptEvent
ASKER
I am getting the following error :
PS C:\scripts> .\Import_GPOs.ps1 -Domain test.lab.com -BackupFolder "C:\GPOBackup\GroupPolicie s\12-18-20 14Lab"
Cannot process the "#requires" statement at line 94 because it is not in the correct format.
The "#requires" statement must be in one of the following formats:
"#requires -shellid <shellID>"
"#requires -version <major.minor>"
"#requires -pssnapin <psSnapInName> [-version <major.minor>]"
At line:1 char:18
+ .\Import_GPOs.ps1 <<<< -Domain test.lab.com -BackupFolder "C:\GPOBackup\GroupPolicie s\12-18-20 14Lab"
+ CategoryInfo : ObjectNotFound: (:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\scripts> .\Import_GPOs.ps1 -Domain test.lab.com -BackupFolder "C:\GPOBackup\GroupPolicie
Cannot process the "#requires" statement at line 94 because it is not in the correct format.
The "#requires" statement must be in one of the following formats:
"#requires -shellid <shellID>"
"#requires -version <major.minor>"
"#requires -pssnapin <psSnapInName> [-version <major.minor>]"
At line:1 char:18
+ .\Import_GPOs.ps1 <<<< -Domain test.lab.com -BackupFolder "C:\GPOBackup\GroupPolicie
+ CategoryInfo : ObjectNotFound: (:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Hi,
The error is triggered for a comment line which start with '#' character. Please try removing all the lines starting with '#' from the script and then try executing with the same format you tried.
The error is triggered for a comment line which start with '#' character. Please try removing all the lines starting with '#' from the script and then try executing with the same format you tried.
ASKER
Here is the line 94 below:
Should I delete the following ??
#Requires -modules ActiveDirectory,GroupPolic y
########################## #######
## Script Options and Parameters
########################## #######
#Requires -version 3
#Requires -modules ActiveDirectory,GroupPolic y
#Version: 2.0
#Define and validate parameters
[CmdletBinding()]
Should I delete the following ??
#Requires -modules ActiveDirectory,GroupPolic
##########################
## Script Options and Parameters
##########################
#Requires -version 3
#Requires -modules ActiveDirectory,GroupPolic
#Version: 2.0
#Define and validate parameters
[CmdletBinding()]
Please delete lines starting with '#' only. Lines starting with '#' are comments and does not impact the script.
You should not be deleting following line.
[CmdletBinding()]
You should not be deleting following line.
[CmdletBinding()]
This is not vbscript - it's a powershell script...the #requires line indicates that version 3 of powershell is needed as well as those indicated modules.. All other # lines are comments.
You will need to run powershell in order to launch this script.
You will need to run powershell in order to launch this script.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
THank you. Looks like I have Powershell Version 2 and version 3 is required.
Downloaded and trying to install PS 3 now...but it tells me that update is not applicable to the computer....I am trying to install it on Windows 2008 R2.
Will post if this resolves the issue
Downloaded and trying to install PS 3 now...but it tells me that update is not applicable to the computer....I am trying to install it on Windows 2008 R2.
Will post if this resolves the issue
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you! Yes. I already installed it framework 4.5. and having issues with this Management Framework 3.0 but I saw it requires SP1 for Windows Server 2008 R2 which I dont have.
installing SP 1 and then powershell 3. Will let you know if this will work.
Other than version of powershell that script is complaining....is there anything else I need according to the errors?
installing SP 1 and then powershell 3. Will let you know if this will work.
Other than version of powershell that script is complaining....is there anything else I need according to the errors?
ASKER
Yes!!! It works now after I downloaded and installed Powershell version 3!!!
ASKER
Excellent! Thank you so much
ASKER
THank you!