Neos.IdentityServer 3.0/Neos.IdentityServer.Common/Neos.IdentityServer.MultiFactor.Utilities.cs
/// <summary>
/// DeleteRemoteConfiguration method implmentation
/// Delete Configuration file cache on Remote server using wsman
/// </summary>
DeleteRemoteConfiguration method implmentation
Delete Configuration file cache on Remote server using wsman
DeleteRemoteConfiguration method implmentation Delete Configuration file cache on Remote server using wsman
internal static void DeleteRemoteConfiguration(MFAConfig cfg, string servername)
        {
            Runspace SPRunSpace = null;
            PowerShell SPPowerShell = null;
            try
            {
                string filePath = CFGUtilities.configcachedir;
                WSManConnectionInfo connectionInfo = new WSManConnectionInfo(false, servername, cfg.WsMan.Port, "/" + cfg.WsMan.AppName, cfg.WsMan.ShellUri, null, cfg.WsMan.TimeOut);
                SPRunSpace = RunspaceFactory.CreateRunspace(connectionInfo);
                connectionInfo.AuthenticationMechanism = AuthenticationMechanism.NegotiateWithImplicitCredential;
                string psscript = @"$fs=[IO.File]::Delete($filepath);";
                SPPowerShell = PowerShell.Create();
                SPPowerShell.Runspace = SPRunSpace;
                SPRunSpace.Open();
                PSCommand command = new PSCommand();
                command.AddCommand("Set-Variable");
                command.AddParameter("Name", "filepath");
                command.AddParameter("Value", filePath);
                SPPowerShell.Commands = command;
                SPPowerShell.AddScript(psscript);
                SPPowerShell.Invoke();
            }
            finally
            {
                if (SPRunSpace != null)
                    SPRunSpace.Close();
                if (SPPowerShell != null)
                    SPPowerShell.Dispose();
            }
        }
internal static void DeleteRemoteConfiguration ( MFAConfig cfg , string servername ) { Runspace SPRunSpace = null ; PowerShell SPPowerShell = null ; try { string filePath = CFGUtilities . configcachedir ; WSManConnectionInfo connectionInfo = new WSManConnectionInfo ( false , servername , cfg . WsMan . Port , " " + cfg . WsMan . AppName , cfg . WsMan . ShellUri , null , cfg . WsMan . TimeOut ) ; SPRunSpace = RunspaceFactory . CreateRunspace ( connectionInfo ) ; connectionInfo . AuthenticationMechanism = AuthenticationMechanism . NegotiateWithImplicitCredential ; string psscript = @"$fs=[IO.File]::Delete($filepath);" ; SPPowerShell = PowerShell . Create ( ) ; SPPowerShell . Runspace = SPRunSpace ; SPRunSpace . Open ( ) ; PSCommand command = new PSCommand ( ) ; command . AddCommand ( " " ) ; command . AddParameter ( " " , " " ) ; command . AddParameter ( " " , filePath ) ; SPPowerShell . Commands = command ; SPPowerShell . AddScript ( psscript ) ; SPPowerShell . Invoke ( ) ; } finally { if ( SPRunSpace != null ) SPRunSpace . Close ( ) ; if ( SPPowerShell != null ) SPPowerShell . Dispose ( ) ; } }
DeleteRemoteConfiguration method implmentation
Delete Configuration file cache on Remote server using wsman
DeleteRemoteConfiguration method implmentation Delete Configuration file cache on Remote server using wsman
cfg
MFAConfig
servername
string