hi luc ,
if yu could suggest how to fix this error .this is one of the functions wherein it will create the content lib based on datasore provided .
[string]$datastore is one of the parameters .do i need to change the string to something else ???
all i am able to conclude is that get-contentlibrary comand which seems available from 11.5 vmware.vimautomation.core module is not working or not avaiable .
Is this still in the HoL environment?
Which Lab?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Works for me
But you have stop/start your PowerShell session after the Update-Module to 11.5
If I don't do that, I also get the same error.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
i have been exposed to all sort of errors
if yu could please check only this portion
function create-contentlib {
[cmdletbinding()]
param (
[parameter(mandatory = $true,
valuefrompipeline = $true,
valuefrompipelinebypropertyname = $true)]
[string]$viserver,
[parameter(mandatory = $true)]
[PSCredential]$Credential_vcenter,
[parameter(mandatory = $true)]
[PSCredential]$Credential_root,
[parameter(mandatory = $true)]
[string]$datastore
)
Connect-VIServer -server $viserver -Credential $Credential_vcenter | Out-Null
$session = New-SSHSession -ComputerName $viserver -Credential $Credential_root
$stream = New-SSHShellStream -SSHSession $session -TerminalName xterm
# Open shell
Invoke-SSHStreamShellCommand -ShellStream $stream -PrompPattern "Shell access is granted" -Command 'shell' | Out-Null
# Run command
$result = Invoke-SSHStreamShellCommand -ShellStream $stream -PrompPattern "]#" -Command 'service-control --status vmware-content-library'
if (($result -join '') -notmatch 'Running:') {
Write-Host "content lib service needs to be restarted " -ForegroundColor Blue
Invoke-SSHCommand -Command "service-control --start vmware-content-library" -SessionId $session_vcsa_id
}
Write-Host "creating content lib" -ForegroundColor Cyan
$conlib = New-ContentLibrary -Name "siteA con lib" -Datastore (Get-Datastore -Name $datastore) -Published -Description "content lib for site A vcenter"
$stream.Close()
Remove-SSHSession -SSHSession $session | Out-Null
}
with following
administrator@regiona.local
VMware1!
root
VMware1!
datastore
If you haven't changed my earlier code, that works for me.
Can you just show me the errors?
Looking at code without knowing what to look for is a waste of time.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
finally it is workng .it has motivated me to do more functions and trouble you more
however i dont know why there was issuse last time related to invoke-sshcoomand as for some reasons it was not able to ssh to vcsa...