Hi,
So I'm trying to cobble together a script that stops the Lotus Domino services, reads the Lotus Domino install directory on a remote server from the registry and then deletes the log files based off reading the registry. Everything works except the file deletion which fails with the error below. The server name is BES2 in Notes, however it DOES have a different host name, but you can ping, access shares, etc via the Notes name.
What syntax do I have wrong? Everything else seems to work fine.
Script:
$Server = Read-Host -Prompt 'Input your server name'
$service=Get-Service -ComputerName $Server|Where-Object {$_.DisplayName -like '*Lotus Domino*'}| foreach { Stop-Service $_}
$w32reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',$Server)
$keypath = 'SOFTWARE\\Lotus\\Domino'
$Dompath = $w32reg.OpenSubKey($keypath)
$Domdata = $dompath.GetValue('DataPath')
Write-Host "Domino is located at "$domdata
Write-Host "Old log file is at "$DomData\log_old.nsf
$command = { (Remove-Item -Path $DomData\log_old.nsf) }
Invoke-Command -ComputerName $Server -ScriptBlock $command
Script output:
PS C:\> c:\remreg3.ps1
Input your server name: bes2
WARNING: Waiting for service 'Lotus Domino Server (CLotusDominodata) (Lotus Domino Server (CLotusDominodata))' to
stop...
WARNING: Waiting for service 'Lotus Domino Server (CLotusDominodata) (Lotus Domino Server (CLotusDominodata))' to
stop...
WARNING: Waiting for service 'Lotus Domino Server (CLotusDominodata) (Lotus Domino Server (CLotusDominodata))' to
stop...
WARNING: Waiting for service 'Lotus Domino Server (CLotusDominodata) (Lotus Domino Server (CLotusDominodata))' to
stop...
WARNING: Waiting for service 'Lotus Domino Server (CLotusDominodata) (Lotus Domino Server (CLotusDominodata))' to
stop...
WARNING: Waiting for service 'Lotus Domino Server (CLotusDominodata) (Lotus Domino Server (CLotusDominodata))' to
stop...
WARNING: Waiting for service 'Lotus Domino Server (CLotusDominodata) (Lotus Domino Server (CLotusDominodata))' to
stop...
WARNING: Waiting for service 'Lotus Domino Server (CLotusDominodata) (Lotus Domino Server (CLotusDominodata))' to
stop...
WARNING: Waiting for service 'Lotus Domino Server (CLotusDominodata) (Lotus Domino Server (CLotusDominodata))' to
stop...
WARNING: Waiting for service 'Lotus Domino Server (CLotusDominodata) (Lotus Domino Server (CLotusDominodata))' to
stop...
Domino is located at C:\Lotus\Domino\data
Old log file is at C:\Lotus\Domino\data\log_old.nsf
[bes2] Connecting to remote server bes2 failed with the following error message : WinRM cannot process the request.
The following error occurred while using Kerberos authentication: Cannot find the computer bes2. Verify that the
computer exists on the network and that the name provided is spelled correctly. For more information, see the
about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (bes2:String) [], PSRemotingTransportException
+ FullyQualifiedErrorId : NetworkPathNotFound,PSSessionStateBroken