diff --git a/src/plugins/interactive_setup/public/cluster_configuration_form.tsx b/src/plugins/interactive_setup/public/cluster_configuration_form.tsx
index a366b5a279284..5888de763a44b 100644
--- a/src/plugins/interactive_setup/public/cluster_configuration_form.tsx
+++ b/src/plugins/interactive_setup/public/cluster_configuration_form.tsx
@@ -42,6 +42,7 @@ import { euiThemeVars } from '@kbn/ui-shared-deps-src/theme';
import type { Certificate } from '../common';
import { DocLink } from './doc_link';
+import { getCommandLineSnippet } from './get_command_line_snippet';
import { SubmitErrorCallout } from './submit_error_callout';
import { TextTruncate } from './text_truncate';
import type { ValidationErrors } from './use_form';
@@ -511,7 +512,7 @@ export const ForgotPasswordPopover: FunctionComponent
- bin/elasticsearch-reset-password --username {username}
+ {getCommandLineSnippet('elasticsearch-reset-password', `--username ${username}`)}
diff --git a/src/plugins/interactive_setup/public/enrollment_token_form.tsx b/src/plugins/interactive_setup/public/enrollment_token_form.tsx
index ef917b0c243fd..f283cf1307a97 100644
--- a/src/plugins/interactive_setup/public/enrollment_token_form.tsx
+++ b/src/plugins/interactive_setup/public/enrollment_token_form.tsx
@@ -30,6 +30,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import type { EnrollmentToken } from '../common';
import { DocLink } from './doc_link';
+import { getCommandLineSnippet } from './get_command_line_snippet';
import { SubmitErrorCallout } from './submit_error_callout';
import { TextTruncate } from './text_truncate';
import type { ValidationErrors } from './use_form';
@@ -260,7 +261,7 @@ export const EnrollmentTokenHelpPopover = () => {
/>
- bin/elasticsearch-create-enrollment-token --scope kibana
+ {getCommandLineSnippet('elasticsearch-create-enrollment-token', '--scope kibana')}
diff --git a/src/plugins/interactive_setup/public/get_command_line_snippet.test.ts b/src/plugins/interactive_setup/public/get_command_line_snippet.test.ts
new file mode 100644
index 0000000000000..0d53a1826be19
--- /dev/null
+++ b/src/plugins/interactive_setup/public/get_command_line_snippet.test.ts
@@ -0,0 +1,38 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { getCommandLineSnippet } from './get_command_line_snippet';
+
+describe('getCommandLineSnippet', () => {
+ const originalNavigator = window.navigator;
+
+ it('should format windows correctly', () => {
+ Object.defineProperty(window, 'navigator', {
+ value: { userAgent: 'Windows' },
+ writable: true,
+ });
+ expect(getCommandLineSnippet('kibana')).toEqual('bin\\kibana.bat');
+ expect(getCommandLineSnippet('kibana', '--silent')).toEqual('bin\\kibana.bat --silent');
+ });
+
+ it('should format unix correctly', () => {
+ Object.defineProperty(window, 'navigator', {
+ value: { userAgent: 'Linux' },
+ writable: true,
+ });
+ expect(getCommandLineSnippet('kibana')).toEqual('bin/kibana');
+ expect(getCommandLineSnippet('kibana', '--silent')).toEqual('bin/kibana --silent');
+ });
+
+ afterAll(function () {
+ Object.defineProperty(window, 'navigator', {
+ value: originalNavigator,
+ writable: true,
+ });
+ });
+});
diff --git a/src/plugins/interactive_setup/public/get_command_line_snippet.ts b/src/plugins/interactive_setup/public/get_command_line_snippet.ts
new file mode 100644
index 0000000000000..51af5b4929140
--- /dev/null
+++ b/src/plugins/interactive_setup/public/get_command_line_snippet.ts
@@ -0,0 +1,12 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+export function getCommandLineSnippet(command: string, args?: string) {
+ const isWindows = window.navigator.userAgent.includes('Win');
+ return `${isWindows ? `bin\\${command}.bat` : `bin/${command}`}${args ? ` ${args}` : ''}`;
+}
diff --git a/src/plugins/interactive_setup/public/verification_code_form.tsx b/src/plugins/interactive_setup/public/verification_code_form.tsx
index 9ff86c63aca7f..d95a840fa7eb1 100644
--- a/src/plugins/interactive_setup/public/verification_code_form.tsx
+++ b/src/plugins/interactive_setup/public/verification_code_form.tsx
@@ -23,6 +23,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import type { IHttpFetchError, ResponseErrorBody } from 'kibana/public';
import { VERIFICATION_CODE_LENGTH } from '../common';
+import { getCommandLineSnippet } from './get_command_line_snippet';
import { SingleCharsField } from './single_chars_field';
import { SubmitErrorCallout } from './submit_error_callout';
import type { ValidationErrors } from './use_form';
@@ -118,9 +119,7 @@ export const VerificationCodeForm: FunctionComponent
values={{
command: (
- {window.navigator.userAgent.includes('Win')
- ? 'bin\\kibana-verification-code.bat'
- : 'bin/kibana-verification-code'}
+ {getCommandLineSnippet('kibana-verification-code')}
),
}}