Powershell terms is not recognized

Hi!

I am trying to run the bellow script to make a bare metal backup of my servers, but several erros appears like these two>

script link:https://gallery.technet.microsoft.com/WSB-Backup-network-email-9793e315

The errors:

Get-WBVolume : The term 'Get-WBVolume' 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.
At C:\SCRIPT\backup_baremetal_2012.ps1:31 char:12
+ $Volumes = Get-WBVolume -AllVolumes | Where-Object { $_.Property -notlike "Criti ...
+            ~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-WBVolume:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

 


New-WBPolicy : The term 'New-WBPolicy' 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.
At C:\SCRIPT\backup_baremetal_2012.ps1:107 char:13
+ $WBPolicy = New-WBPolicy
+             ~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (New-WBPolicy:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException



I think it is missing the module for windows.backupserver but I am not being able to find the solution.

I am running these script in Server 2012 R2 and Server 2008 R2 and both systems show the same errors.

Thanks!
edu87Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Frans BrouwerSenior Systems AdministratorCommented:
#Initialize WSB cmdlets
if ( (Get-PSSnapin -Name Windows.ServerBackup -ErrorAction SilentlyContinue) -eq $null )
{
    Add-PsSnapin Windows.ServerBackup
}

this should be without error , can you check
edu87Author Commented:
Even with this part removed the same error occurs
Frans BrouwerSenior Systems AdministratorCommented:
just test this part - its crucial to the whole
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

edu87Author Commented:
Which that piece of code the same error continue to happen, but there is one more different message:

Add-PsSnapin : No snap-ins have been registered for Windows PowerShell version 4.
At C:\SCRIPT\backup_baremetal_2012.ps1:17 char:5
+     Add-PsSnapin Windows.ServerBackup
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (Windows.ServerBackup:String) [Add-PSSnapin], PSArgumentExce
   ption
    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
Did you install Windows Server Backup Features and subordinate items on the server?
You must need this and without this you dont have any cmdlets you are using in your script.

Follow the set of instructions to install them:
https://technet.microsoft.com/en-us/library/cc732081.aspx
Hope this helps.
edu87Author Commented:
Yes. On one of the servers that is Windows Server 2008 R2 I made that.
On Windows Server 2012 R2 servers there aren´t the option to add the Command-line Tools, but just the option WIndows Server Backup (that is already installed).
Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
Silly question but did you try after restarting the server following the installation?
edu87Author Commented:
Rebooted now, and the problem continues
Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
Can you see anything displayed when you try :
Get-Command –Module WindowsServerBackup

Open in new window

edu87Author Commented:
No, the answer for this command is empty.
Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
open Powershell_ise and try Get-Command –Module WindowsServerBackup
Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
there is a 32 bit and 64 bit of powershell.exe and which might be causing the issue.
one of them is in syswow64 and other in Program files (x86)
try running in both and also in powershell_ise
edu87Author Commented:
Same thing..the result is empty even by PowerShell ISE running as administrator.
Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
in that case reinstall the windows server backup and subordinate features again and restart test.
edu87Author Commented:
On Windows Server 2012 R2, using the 64bits returned some CmdLets!
But on Windows Server 2008 R2 using the 64bits don´t the responde is empty yet.
Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
run on 2012 server: which should display the WSB added or try add-pssnapin again.
get-pssnapin -registered 

Open in new window

edu87Author Commented:
The response is empty for the command.
Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
have you tried Add-pssnapin  again
edu87Author Commented:
I tryed to run the script using the c:\system32\windowspowershell and the script is now runing fine.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.